Re: Using &H with a variable
You should distingush between Hex notation and Hex string of a number.
&HAA and 170 are two ways to denote the same decimal number 170.
We say: The Hex string of 170 is "AA".
Try this in Immediate window, it will help you to understand:
Code:
? &HAA
170
? Hex$(&HAA)
AA
? Hex$(170)
AA
? CLng("&H" & "AA")
170
? Hex$(CLng("&H" & "AA"))
AA
? Hex$("&H" & "AA")
AA
If you want to write Hex String of a number to output file with Put, you have to convert the number to Hex String first:
Code:
Put #1, Hex$("&H" & Text1.Text)
Put #1, Hex$(&H27110) ' = "27110"
Put #1, Hex$(170) ' = "AA"
Put #1, "&H" & Hex$(170) ' = "&HAA"
Re: Using &H with a variable
if you entered "&Hff" in a textbox1.text, this would give you the value:
msgbox val(textbox1.text)