hexidecimal conversion

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

bear23Asked:
Who is Participating?
 
aioakeimConnect With a Mentor Commented:
try something like this
i think it will hepl u
function hextochr(strsms)

Dec2Chr = ""
Hex2Dec = 0

for j=1 to len(strsms)
      InputData = Mid(strsms,j,2)
      j=j+1
      HexStep = 0
      DecOut = 0

      select case InputData
            case "13"            Dec2Chr = Dec2Chr & "Γ"
            case "10"            Dec2Chr = Dec2Chr & "Δ"
            case "19"            Dec2Chr = Dec2Chr & "Θ"
            case "1A"            Dec2Chr = Dec2Chr & "Ξ"
            case "14"            Dec2Chr = Dec2Chr & "Λ"
            case "16"            Dec2Chr = Dec2Chr & "Π"
            case "18"            Dec2Chr = Dec2Chr & "Σ"
            case "12"            Dec2Chr = Dec2Chr & "Φ"
            case "17"            Dec2Chr = Dec2Chr & "Ψ"
            case "15"            Dec2Chr = Dec2Chr & "Ω"
            case "41","61"      Dec2Chr = Dec2Chr & "Α"
            case "42","62"      Dec2Chr = Dec2Chr & "Β"
            case "45","65"      Dec2Chr = Dec2Chr & "Ε"
            case "48","68"      Dec2Chr = Dec2Chr & "Η"
            case "49","69"      Dec2Chr = Dec2Chr & "Ι"
            case "4B","6B"      Dec2Chr = Dec2Chr & "Κ"
            case "4D","6D"      Dec2Chr = Dec2Chr & "Μ"
            case "4E","6E"      Dec2Chr = Dec2Chr & "Ν"
            case "4F","6F"      Dec2Chr = Dec2Chr & "Ο"
            case "50","70"      Dec2Chr = Dec2Chr & "Ρ"
            case "54","74"      Dec2Chr = Dec2Chr & "Τ"
            case "58","78"      Dec2Chr = Dec2Chr & "Χ"
            case "59","79"      Dec2Chr = Dec2Chr & "Υ"
            case "5A","7A"      Dec2Chr = Dec2Chr & "Ζ"
            case "55","75"      Dec2Chr = Dec2Chr & "U"
            case "47","67"      Dec2Chr = Dec2Chr & "G"
            case "43","63"      Dec2Chr = Dec2Chr & "C"
            case "4C","6C"      Dec2Chr = Dec2Chr & "L"
            case "44","64"      Dec2Chr = Dec2Chr & "D"
            case "46","66"      Dec2Chr = Dec2Chr & "F"
            case "4A","6A"      Dec2Chr = Dec2Chr & "J"
            case "51","71"      Dec2Chr = Dec2Chr & "Q"
            case "52","72"      Dec2Chr = Dec2Chr & "R"
            case "53","73"      Dec2Chr = Dec2Chr & "S"
            case "56","76"      Dec2Chr = Dec2Chr & "V"
            case "57","77"      Dec2Chr = Dec2Chr & "W"
            case "20"            Dec2Chr = Dec2Chr & " "
            case "3A"            Dec2Chr = Dec2Chr & ":"
            case "2E"            Dec2Chr = Dec2Chr & "."
            case "30"            Dec2Chr = Dec2Chr & "0"
            case "31"            Dec2Chr = Dec2Chr & "1"
            case "32"            Dec2Chr = Dec2Chr & "2"
            case "33"            Dec2Chr = Dec2Chr & "3"
            case "34"            Dec2Chr = Dec2Chr & "4"
            case "35"            Dec2Chr = Dec2Chr & "5"
            case "36"            Dec2Chr = Dec2Chr & "6"
            case "37"            Dec2Chr = Dec2Chr & "7"
            case "38"            Dec2Chr = Dec2Chr & "8"
            case "39"            Dec2Chr = Dec2Chr & "9"


      end select
next
      hextochr = ""
      hextochr = Dec2Chr

End function
0
 
aioakeimCommented:
these strande characters (like "Γ") are greek dont be confused
0
 
bear23Author 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
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
SunBowCommented:
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
0
 
bear23Author 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.....
0
 
dcryslerCommented:
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....
0
 
SunBowCommented:
Done?
What was the answer?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.