|
-
Nov 19th, 2009, 01:04 AM
#1
Thread Starter
New Member
How to convert hex to ascii?
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..
-
Nov 19th, 2009, 06:19 AM
#2
Re: How to convert hex to ascii?
Thread moved from the 'CodeBank VB6' forum (which is for you to post your code examples, not questions) to the 'VB6' forum
-
Nov 19th, 2009, 09:01 AM
#3
Re: How to convert hex to ascii?
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"
-
Nov 19th, 2009, 01:08 PM
#4
Fanatic Member
Re: How to convert hex to ascii?
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
-
Nov 19th, 2009, 01:21 PM
#5
Re: How to convert hex to ascii?
 Originally Posted by Justa Lol
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?
Code:
MsgBox "Blue: " & vbBlue & " " & &HFF0000
MsgBox "Red: " & vbRed & " " & &H0000FF
The VB Hex function works perfectly, i.e., Val(&H0000FF)=vbRed & Hex(vbRed)="FF"
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.
-
Nov 19th, 2009, 01:27 PM
#6
Fanatic Member
Re: How to convert hex to ascii?
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?
-
Nov 19th, 2009, 03:05 PM
#7
Re: How to convert hex to ascii?
 Originally Posted by Justa Lol
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.
-
Nov 19th, 2009, 03:08 PM
#8
Fanatic Member
Re: How to convert hex to ascii?
well now i understand why...
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
|