With VB Script you can just define a global variable then you can call it and change it from anywhere in the code, even in Javascript if you added that to the hta.
<script language="VBScript" type="text/vbscript">
Dim MyValue
Sub storeValue(theValue)
If theCondition Then
MyValue = theValue
Else
MyValue = "Something Else"
End If
End Sub
Sub retrieveValue
MsgBox MyValue
End Sub
</script>
<script language="javascript" type="text/javascript">
function clearValue() {
MyValue = ""
}
</script>
Edit: I wanted to edit to say, I'm actually doing what you mentioned for some of my variables in an HTA using, except I'm storing the value of InnerHTML as the "value" and my div is set to "display:none."
<div id=theDiv style="display:none"></div>
Then
theDiv.InnerHTML = MyValue
or MyValue = theDiv.InnerHTML
etc