From: GS on
on 5/28/2010, Mike Williams supposed :
> "GS" <gesansom(a)netscape.net> wrote in message
> news:htp75e$69q$1(a)news.eternal-september.org...
>> Oops! Seem to have lost some code somehow. Final solution is: Function
>> Hex2Dec(HexString As String) As String
>> Dim i As Long
>> For i = 1 To Len(HexString) Step 2
>> Hex2Dec = Hex2Dec & CStr(Val("&H" & Mid(HexString, i, 2)))
>> Next i
>> End Function
>
> Are you certain that's exactly what you want? It doesn't look right to me.
> The reason I'm saying that is because given the output string it is actually
> impossible to reliably discover what the original input hex string was, even
> if you know the exact length of the original input hex string, and especially
> if you do not, which is ringing alarm bells here. Are you absolutely sure it
> is what you want?
>
> Mike

Hi Mike,
Derek has provided a solution for this issue. It does need a delimited
DecString to work but I can live with that. See my reply to his reply
of my last post to you for the results.

Thanks again for raising the issue!

regards,

--
Garry

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


From: Henning on

"Derek" <derekrss(a)yahoo.ca> skrev i meddelandet
news:527036a6-1c91-40a9-8f89-673eb78cd857(a)q13g2000vbm.googlegroups.com...
On May 28, 4:13 pm, GS <gesan...(a)netscape.net> wrote:
> I'm thinking that I should retain the delimited values and dump it into
> an array using Split(). This would, at least, preserve the individual
> values return by the Hex2Dec function. Problem is, as you say, how to
> determine what the original string was from the resulting string. For
> example, returning Hex(14) returns "E" and not "0E".
>
> Any suggestions you have would be greatly appreciated.
>

Returning RIGHT$(HEX$(256 + 14), 2) would return "0E"

Cheers

Derek

----
And so will Right$("0" & Hex$(14),2)

/Henning


From: Henning on

"GS" <gesansom(a)netscape.net> skrev i meddelandet
news:htoutg$r7r$1(a)news.eternal-september.org...
> 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
>
>

That is not a string of Hex values, just a string of Hex digits.
For Hex values s = Chr$(14) & Chr$(14) & Chr$(0) & ....

/Henning


From: GS on
Henning wrote :
> "GS" <gesansom(a)netscape.net> skrev i meddelandet
> news:htoutg$r7r$1(a)news.eternal-september.org...
>> 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
>>
>>
>
> That is not a string of Hex values, just a string of Hex digits.
> For Hex values s = Chr$(14) & Chr$(14) & Chr$(0) & ....
>
> /Henning

No, it's not a string of Hex values! It's a string of Dec values
created by passing the original HexString (or Hex digits, as you say)
to Excel's Analysis Toolpak Hex2Dec() function.
For the record, Chr$(14) returns "", same as does Chr$(&H0E).

The point of the exercise is to duplicate what Excel's Hex2Dec() does
using VB[A]. What concerns me is the user claims to get different
result for Chr$(&H0E), reporting that it returns "3045"!<???> I suspect
he's using either a custom Hex2Dec() function, or a custom Chr()
function, or both.

regards,

--
Garry

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


From: GS on
on 5/28/2010, Henning supposed :
> "Derek" <derekrss(a)yahoo.ca> skrev i meddelandet
> news:527036a6-1c91-40a9-8f89-673eb78cd857(a)q13g2000vbm.googlegroups.com...
> On May 28, 4:13 pm, GS <gesan...(a)netscape.net> wrote:
>> I'm thinking that I should retain the delimited values and dump it into
>> an array using Split(). This would, at least, preserve the individual
>> values return by the Hex2Dec function. Problem is, as you say, how to
>> determine what the original string was from the resulting string. For
>> example, returning Hex(14) returns "E" and not "0E".
>>
>> Any suggestions you have would be greatly appreciated.
>>
>
> Returning RIGHT$(HEX$(256 + 14), 2) would return "0E"
>
> Cheers
>
> Derek
>
> ----
> And so will Right$("0" & Hex$(14),2)
>
> /Henning

True for this pair of hex digits. Not going to work for all pairs as
does using '256'. Results using "0" instead of '256':

Original hexString: "0E0E00000505000C20450164A5A5"
Returns DecString: "14,14,0,0,5,5,0,12,32,69,1,100,165,165"
Restore DecString returns: "EE00550C2045164A5A5", which is not what we
want.

regards,

--
Garry

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