I'm a newbie, and learn vb6. I have a form with txtHex as input text, txtAscii as output and a button cmdConvert. How to make the code to convert from hex to ascii according to the form? Thx 4 your help..
Printable View
I'm a newbie, and learn vb6. I have a form with txtHex as input text, txtAscii as output and a button cmdConvert. How to make the code to convert from hex to ascii according to the form? Thx 4 your help..
Thread moved from the 'CodeBank VB6' forum (which is for you to post your code examples, not questions) to the 'VB6' forum
Welcome to the forums.
ASCII pertains to text (i.e., characters). Hex pertains to numbers.
To convert Hex to a number, use the Val() function and precede the hex with the &H prefix.
Val(&HFF) = 255 and Hex(255) = "FF"
but LaVolpe once i tried hex in vb its totally messed up, hex in vb is not red green blue, its blue green red.
for example FF0000 will be displayed as blue and 0000FF will be red...
by the way, decimal of hex could be converted with the windows calculator..
http://www.vbforums.com/showthread.php?t=231962
Because &HFF0000 is Blue and &H0000FF is Red. Do you doubt me?
The VB Hex function works perfectly, i.e., Val(&H0000FF)=vbRed & Hex(vbRed)="FF"Code:MsgBox "Blue: " & vbBlue & " " & &HFF0000
MsgBox "Red: " & vbRed & " " & &H0000FF
If whatever app you are using needs the hex displayed in reverse order, it is up to you to reverse it. If you are trying to extract RGB values from a bitmap, know the bitmap structure as most are BGR, not RGB.
well that means its wrong with the hex code you use in any other language.
how come that its the opposite in any website programming language or java for example?
Maybe Java is backwards.
Open the scientific calculator (calc.exe) in Hex mode and enter in FF0000 and convert that to decimal and you will get a return value of 16711680 (vbBlue). It doesn't really matter which is backwards and which is not, it only matters that you know what format the app requires.
well now i understand why...