Click here to Skip to main content
15,886,770 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i want to convert 494E4352454153494E47 this into 2-digit hex value through VB6 can anyone help me

I have a code which convert to hex

slpe = Combo5.Text
bytes = StrConv(slpe, vbFromUnicode)
slpe = ""
For i = LBound(bytes) To UBound(bytes)
slpe = slpe & Format$(Hex$(bytes(i)), "00")
Next i
Combo5.Text = slpe
slpe = StrConv(bytes, vbUnicode)
rs.Fields("slope").Value = Combo5.Text

if i use this code i'm able to convert INCREASING as 494E4352454153494E47 this and store in MSAccess
but i want to convert as 2-digit hex code
is it possible?

What I have tried:

slpe = Combo5.Text
bytes = StrConv(slpe, vbFromUnicode)
slpe = ""
For i = LBound(bytes) To UBound(bytes)
slpe = slpe & Format$(Hex$(bytes(i)), "00")
Next i
Combo5.Text = slpe
slpe = StrConv(bytes, vbUnicode)
rs.Fields("slope").Value = Combo5.Text
Posted
Comments
Richard MacCutchan 14-Feb-18 7:08am    
That string is already 2-digit hex.
Member 13396059 14-Feb-18 7:21am    
no,my complete hex value of 21 fields is 43484F4C456E6420506F696E742F5354442F522E422094E494C250C0C0C0C0C0C0C0C0C0C494E4352454153494E470C0C0C6F6E62616E67616C6F7265

but i want to make it as 21 bytes
1 field = 2bytes

how can i do that
Richard MacCutchan 14-Feb-18 7:51am    
You need to take each digit in turn and convert it to its hex value. For the integers 0 to 9 you subtract the base, i.e. '0', or HEX(30). For characters A to F, you subtract the base 'A', or HEX(41), and add 10 to get the values 10 to 15. The first value of each pair is the left half of the new character, and the second value is the right half.
Member 13396059 14-Feb-18 7:21am    
43484F4C456E6420506F696E742F5354442F522E422094E494C25
0C0C0C0C0C0C0C0C0C0C494E4352454153494E470C0C0C6F6E62616E67616C6F7265
Dave Kreskowiak 14-Feb-18 8:13am    
You're going to have to describe what you mean by "converting ... into 2 hex digits". Compression is out of the question, so the only thing you could possibly be talking about is breaking up that string into an array of strings, each 2 digits long.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900