Passing Hex values

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: Passing Hex values

1. Suneera Guest

## Passing Hex values

He All,

How can I pass hex values as string into a function.
For example I want to pass (5A C9 02)(any number of) as a single string,
where the receiptant is a string variable

Suneera

2. Sam Barrett Guest

## Re: Passing Hex values

>How can I pass hex values as string into a function.
>For example I want to pass (5A C9 02)(any number of) as a single string,
>where the receiptant is a string variable

Suneera, You can use the hex function to convert a number into a string of
hexadecimal digits. Hex(5949698) will return the string "5AC902". Hope
this helps! --Sam

Sam Barrett, MTL Systems, Inc., mailto:sam@mtl.com
Brainbench MVP, http://www.brainbench.com

And the things that you have heard...commit these to faithful
men who will be able to teach others also. 2 Timothy 2:2

3. Bob Butler Guest

## Re: Passing Hex values

"Suneera" <suneera77@yahoo.com> wrote in message
news:3ae3c417\$1@news.devx.com...
>
> He All,
>
> How can I pass hex values as string into a function.
> For example I want to pass (5A C9 02)(any number of) as a single string,
> where the receiptant is a string variable

If I understand correctly...

Dim s As String
s=Chr\$(CLng("&H5A")) & Chr\$(CLng("&HC9")) & Chr\$(CLng("&H02")) ...
Call MySub(s)

If you have control over the called routine I'd suggest changing it to a
byte array instead. Strings in VB are stored as unicode so you are
converting ascii->unicode->ascii and that slows things down and can lead to
some strange issues like:
If chr\$(130)<chr\$(255) Then Msgbox "you never get to this!"

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise
 Questions? Contact us. C++ Web Development Wireless Latest Tips Open Source