Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - string to hex value

Reply
 
Old 08-13-2008   #1 (permalink)
Big D


 
 

string to hex value

How do I go about converting a string value to Hex? I don't know if there is
something built in. I did start writng the code with a for loop but I feel
that I am doing it the hard way. I am thinking I would be able to pass in a
value of 01 the function would return back 30 31.


For example,
String = 01
HexValue=30 31

If String was 11
HexValue=31 30


----------Code snippet of my approach which I feel is not
efficient.------------
For k = 30 To 39 '0-9
For j = 30 To 39 '0-9
Next
Next




My System SpecsSystem Spec
Old 08-13-2008   #2 (permalink)
Pegasus \(MVP\)


 
 

Re: string to hex value


"Big D" <BigDaddy@xxxxxx> wrote in message
news:uZkif0T$IHA.4800@xxxxxx
Quote:

> How do I go about converting a string value to Hex? I don't know if there
> is something built in. I did start writng the code with a for loop but I
> feel that I am doing it the hard way. I am thinking I would be able to
> pass in a value of 01 the function would return back 30 31.
>
>
> For example,
> String = 01
> HexValue=30 31
>
> If String was 11
> HexValue=31 30
>
>
> ----------Code snippet of my approach which I feel is not
> efficient.------------
> For k = 30 To 39 '0-9
> For j = 30 To 39 '0-9
> Next
> Next
Use the inbuilt Asc function, e.g. like so:
name = "012345 Big D"
line = ""
For i = 1 To Len(name)
line = line & Asc(Mid(name, i, 1)) & " "
Next
WScript.Echo line


My System SpecsSystem Spec
Old 08-13-2008   #3 (permalink)
Tom Lavedas


 
 

Re: string to hex value

On Aug 13, 8:24 am, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Big D" <BigDa...@xxxxxx> wrote in message
>
> news:uZkif0T$IHA.4800@xxxxxx
>
>
>
Quote:

> > How do I go about converting a string value to Hex? I don't know if there
> > is something built in. I did start writng the code with a for loop but I
> > feel that I am doing it the hard way. I am thinking I would be able to
> > pass in a value of 01 the function would return back 30 31.
>
Quote:

> > For example,
> > String = 01
> > HexValue=30 31
>
Quote:

> > If String was 11
> > HexValue=31 30
>
Quote:

> > ----------Code snippet of my approach which I feel is not
> > efficient.------------
> > For k = 30 To 39 '0-9
> > For j = 30 To 39 '0-9
> > Next
> > Next
>
> Use the inbuilt Asc function, e.g. like so:
> name = "012345 Big D"
> line = ""
> For i = 1 To Len(name)
> line = line & Asc(Mid(name, i, 1)) & " "
> Next
> WScript.Echo line
This seems to be one tiny step short of Hex. That is, ...

line = line & Hex(Asc(Mid(name, i, 1))) & " "

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Find a string within a variable string PowerShell
problems with $var | select-string -pattern $string -q PowerShell
How export-csv deals with string versus string[] PowerShell
String PRODUCT_NAME was not found in string table Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46