From: KAKA on
How to do Hex transfer to string by vb script ?
I want to transfer to the 4D006F006E00690074006F0072 to string, and
ignore the 00 . The string is Monitor
Thanks.
From: McKirahan on
"KAKA" <KAKA(a)discussions.microsoft.com> wrote in message
news:8447B304-3580-4E58-97F5-195060B63B2C(a)microsoft.com...
> How to do Hex transfer to string by vb script ?
> I want to transfer to the 4D006F006E00690074006F0072 to string, and
> ignore the 00 . The string is Monitor

There may be a better way but will this help?

WScript.Echo Hex2String("4D006F006E00690074006F0072")

Function Hex2String()
Dim a, i, s, x, y, z
a = Split(c,"00")
For i = 0 To UBound(a)
x = Left(a(i),1)
y = Right(a(i),1)
z = 16*x+InStr("123456789ABCDEF",y)
s = s & Chr(z)
Next
Hex2String = s
End Function


From: Evertjan. on
McKirahan wrote on 12 dec 2007 in microsoft.public.scripting.vbscript:

> "KAKA" <KAKA(a)discussions.microsoft.com> wrote in message
>> How to do Hex transfer to string by vb script ?
>> I want to transfer to the 4D006F006E00690074006F0072 to string, and
>> ignore the 00 . The string is Monitor
>
> There may be a better way but will this help?
>
> WScript.Echo Hex2String("4D006F006E00690074006F0072")
>
> Function Hex2String()

Function Hex2String(c)

> Dim a, i, s, x, y, z
> a = Split(c,"00")
> For i = 0 To UBound(a)
> x = Left(a(i),1)
> y = Right(a(i),1)
> z = 16*x+InStr("123456789ABCDEF",y)
> s = s & Chr(z)
> Next
> Hex2String = s
> End Function


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
From: McKirahan on
"Evertjan." <exjxw.hannivoort(a)interxnl.net> wrote in message
news:Xns9A0461F8EF2ACeejj99(a)194.109.133.242...
> McKirahan wrote on 12 dec 2007 in microsoft.public.scripting.vbscript:
>
> > "KAKA" <KAKA(a)discussions.microsoft.com> wrote in message
> >> How to do Hex transfer to string by vb script ?
> >> I want to transfer to the 4D006F006E00690074006F0072 to string, and
> >> ignore the 00 . The string is Monitor
> >
> > There may be a better way but will this help?
> >
> > WScript.Echo Hex2String("4D006F006E00690074006F0072")
> >
> > Function Hex2String()
>
> Function Hex2String(c)

Thanks for catching my error.

I originally had it as:

Const c = "4D006F006E00690074006F0072"
WScript.Echo c & " = " & Hex2String()
Function Hex2String()

but changed it at the last minute.


From: Paul Randall on

"McKirahan" <News(a)McKirahan.com> wrote in message
news:MP2dnXWzX6iFdMLanZ2dnUVZ_s2tnZ2d(a)comcast.com...
> "Evertjan." <exjxw.hannivoort(a)interxnl.net> wrote in message
> news:Xns9A0461F8EF2ACeejj99(a)194.109.133.242...
>> McKirahan wrote on 12 dec 2007 in
>> microsoft.public.scripting.vbscript:
>>
>> > "KAKA" <KAKA(a)discussions.microsoft.com> wrote in message
>> >> How to do Hex transfer to string by vb script ?
>> >> I want to transfer to the 4D006F006E00690074006F0072 to
>> >> string, and
>> >> ignore the 00 . The string is Monitor
>> >
>> > There may be a better way but will this help?
>> >
>> > WScript.Echo Hex2String("4D006F006E00690074006F0072")
>> >
>> > Function Hex2String()
>>
>> Function Hex2String(c)
>
> Thanks for catching my error.
>
> I originally had it as:
>
> Const c = "4D006F006E00690074006F0072"
> WScript.Echo c & " = " & Hex2String()
> Function Hex2String()
>
> but changed it at the last minute.

I like your script. I ignored the '00's (as suggested by the OP), and
thus assumed that they might not be a reliable character separator.
Your script reqires the '00's to be there, which is not quite the same
as ignoring them. Now I'm beginning to think that perhaps the OP just
needs a routine to convert 16-bit Unicode to 8-bit Ansi. Doing large
scale conversions might be more efficiently accomplished using the
Microsoft.XMLDOM or ADODB.Stream objects.

Perhaps the OP will let us know.

-Paul Randall