We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

hexidecimal conversion

bear23
bear23 asked
on
Medium Priority
654 Views
Last Modified: 2012-08-13
I have a text file that is all in hexidecimal. I need a code in vb 6 that will convert the hexidecimal into characters, How can I do this

Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
these strande characters (like "Γ") are greek dont be confused

Author

Commented:
the text file looks like this:
sample, alot more to it:
C8001FF0F8C4C3F1F0F4F0F3F2F3E5D5C6D3D6
C4001FC9D5F7F1F1F0F0F0F0F6404040404040

how could I turn this into characters. I tired your code but nothing happened

Commented:
homework?
The conversion should go from numeric to alpha using the chr() function
But first you need the number, which you do not have.
You need to read in the hex pairs, remembering that the first character read in represents a multiple of 16.
I prefer doing it in additive math, adding the decimal equivalent of first number to the base (such as 65)

But it can be done well enough with a case, like the above, for changing 0-f to 0-15, multiply by 16, add the next number and convert

Author

Commented:
no it is not homework. I have a hex file like I listed above and need to find a way to convert it into characters & numbers.

ANother words be able to read it.....

Commented:
SubBow has it right, I just thought I'd add this in case it wasn't clear.   The valid values for hex are 0-9 and A-F (these represent 10-15)  Hexadecimal values are in pairs, so your test data above breaks down to

C8 00 1F F0 F8....

C=12
8=8
thus the decimal value = (12*16) + 8 = 200

so your test data then converts to

200 0 31 240 248 .....

You can then compare the decimal values to the ascii table (www.asciitable.com) to convert from decimal to text.  Of course you don't have to do this manually,  as noted above the chr() function will do if for you.  This is, assuming the data was encoded as ascii text.  Unicode uses two bytes per character....

Commented:
Done?
What was the answer?
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.