From: GS on
Does anyone have a solution to convert a Hex string to its equivalent
Dec or Chr() values?

Thanks in advance

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


From: Auric__ on
On Fri, 28 May 2010 06:24:46 GMT, GS wrote:

> Does anyone have a solution to convert a Hex string to its equivalent
> Dec or Chr() values?
>
> Thanks in advance

To convert from Hex$ to a numerical value, just prepend "&h" to the beginning
of the number, then run it through Val:
x& = Rnd * &H7FFFFFFF
y$ = Hex$(x&)
z& = Val("&h" & y$)
MsgBox x& & " -- " & y$ & " -- " & z&

--
There's none so blind as those who refuse to listen.
-- Daffy Duck
From: Henning on
GS t�nkte v�ldigt h�rt :
> Does anyone have a solution to convert a Hex string to its equivalent Dec or
> Chr() values?
>
> Thanks in advance

If you have a string with binary data.

For i = 1 To Len(thestring)
myByteArr(i) = Asc(Mid$(thestring, i, 1)
Next

/Henning


From: Tom Shelton on
After serious thinking GS wrote :
> Does anyone have a solution to convert a Hex string to its equivalent Dec or
> Chr() values?
>
> Thanks in advance

Dim v As Integer = Convert.ToInt32("0A", 16)

HTH

--
Tom Shelton


From: GS on
Thanks to all for replying! Unfortunately, after diligently trying
each, none of the suggestions are working as expected. Here's what I'm
trying to do:

I have the following string of Hex values:
"0E0E00000505000C20450164A5A5"

which I need to convert to a delimited string of Dec values. The
expected result is:
"14,14,0,0,5,5,0,12,32,69,1,100,165,165"

Since the source string of Hex values are paired, a delimited version
of this would be:
"0E,0E,00,00,05,05,00,0C,20,45,01,64,A5,A5"

I was able to get the result using an Excel WorkSheetFunction provided
by the Analyss Toolpak addin called Hex2Dec(). I would like to
duplicate that function in VB6.

Thanks in advance, again, for any suggested solutions.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc