Home All Groups Group Topic Archive Search About

Instantiate a byte array with hex values

Author
11 Apr 2006 2:55 PM
Raterus
I'm trying to do something like this, but can't get the syntax correct, can someone help?

Dim myBytes() As Byte = {0x2b, 0x0c, 0x02, 0x87, 0x73, 0x1c, 0x00, 0x85, 0x4A}

Thanks!

Author
11 Apr 2006 3:06 PM
Herfried K. Wagner [MVP]
"Raterus" <rate***@hotmail.com> schrieb:
>Dim myBytes() As Byte = {0x2b, 0x0c, 0x02, 0x87, 0x73,
>0x1c, 0x00, 0x85, 0x4A}

\\\
Dim Bytes() As Byte = {&H2B, &HC, &H2, &H87, ...}
///

Simply replace '0x' with '&H' and remove leading zeros.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
11 Apr 2006 3:24 PM
Raterus
Thanks, that work great!  It's so hard to search for things like that!!

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:ecc0xlXXGHA.4716@TK2MSFTNGP02.phx.gbl...
> "Raterus" <rate***@hotmail.com> schrieb:
>>Dim myBytes() As Byte = {0x2b, 0x0c, 0x02, 0x87, 0x73,
>>0x1c, 0x00, 0x85, 0x4A}
>
> \\\
> Dim Bytes() As Byte = {&H2B, &HC, &H2, &H87, ...}
> ///
>
> Simply replace '0x' with '&H' and remove leading zeros.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>