Link to home
Start Free TrialLog in
Avatar of John Cournoyer
John CournoyerFlag for United States of America

asked on

create byte array in vb.net

newbie question,
how do i create a char array in vb.net.  i'm translating the following code to vb and am able to create an unsigned int array in vb, but not a char array with hex bytes as shown in the last line of the following example.  

// c code
unsigned int ar0[11] = {5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}  
unsigned char ar1[16] = {0x33,0x73,0x3b,0x26,0x63,0x23,0x6b,0x76,0x3e,0x7e,0x36,0x2b,0x6e,0x2e,0x66,0x7b}

'vb code
Dim ar0 As UInt16() = {5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4}  // works
Dim ar1 As Char() = {0x33, 0x73, 0x3b, 0x26, 0x63, 0x23, 0x6b, 0x76, 0x3e, 0x7e, 0x36, 0x2b, 0x6e, 0x2e, 0x66, 0x7b} // no work

 
SOLUTION
Avatar of nishikanth
nishikanth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Cournoyer

ASKER

Thanks nishikanth and Karun!  You've both answered my question and I will split the points between you.  I have one more question that I need help with.  If I have a very large array of bytes to enter into my array... the &_ does not allow me to continue to the next line.  What am I doing wrong here?

 Dim ar1 As Byte() = {&H33, &H73, &H3B, &H26, &H63, &H23, &H6B, &H76, &H3E, &H7E, &H36, &_
                                &HD3, &H93, &HDB, &H6, &H43, &H3, &H4B, &H96, &HDE, &H9E, &HD6, &_
                                &HB, &H4E, &HE, &H46, &H9B, &H57, &H17, &H5F, &H82, &HC7, &H87, &HCF}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial