Instantiate a byte array with hex values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raterus

    #1

    Instantiate a byte array with hex values

    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!
  • Herfried K. Wagner [MVP]

    #2
    Re: Instantiate a byte array with hex values

    "Raterus" <raterus@hotmai l.com> schrieb:[color=blue]
    >Dim myBytes() As Byte = {0x2b, 0x0c, 0x02, 0x87, 0x73,
    >0x1c, 0x00, 0x85, 0x4A}[/color]

    \\\
    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/>

    Comment

    • Raterus

      #3
      Re: Instantiate a byte array with hex values

      Thanks, that work great! It's so hard to search for things like that!!

      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:ecc0xlXXGH A.4716@TK2MSFTN GP02.phx.gbl...[color=blue]
      > "Raterus" <raterus@hotmai l.com> schrieb:[color=green]
      >>Dim myBytes() As Byte = {0x2b, 0x0c, 0x02, 0x87, 0x73,
      >>0x1c, 0x00, 0x85, 0x4A}[/color]
      >
      > \\\
      > 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/>[/color]

      Comment

      Working...