|
-
Aug 25th, 2007, 06:33 PM
#1
Thread Starter
Member
Using &H with a variable
Hello, I am building a program to edit stuff at the binary level. I found that by using &HAA, for example, it would write AA in hex. My problem is I have variables that I want to write from text boxes. And I can not do &H & text1.text!
And even if i convert them to hex, and do put #1, &H27110, var, it writes it into the file as asc
Any help is greatly appreciated!
-
Aug 25th, 2007, 09:14 PM
#2
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"
-
Aug 25th, 2007, 10:27 PM
#3
Re: Using &H with a variable
if you entered "&Hff" in a textbox1.text, this would give you the value:
msgbox val(textbox1.text)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|