problem with byte array in an arraylist

S

Saurabh Kumar

HELP!

The below code seems simple, but just does not seem to work! I am trying to
pass a byte array through a arraylist, to another byte array...but i keep on
getting unable to convert object type to 1 dimentional byte array....what is
wrong?

Dim a(2) As Byte
Dim b(2) As Byte
Dim arr As New ArrayList


a(0) = 45
a(1) = 34
arr.Add(a)
b = arr.Item(0)
MessageBox.Show(CStr(b(1)))

Thanks.
 
I

Imran Koradia

The error message is correct. You need to convert the object returned by
arr.Item(0) to a 1-dimensional byte array. Here's how:

b = CType(arr.Item(0), Byte())

hope that helps..
Imran.
 
S

Saurabh Kumar

thanks!

Imran Koradia said:
The error message is correct. You need to convert the object returned by
arr.Item(0) to a 1-dimensional byte array. Here's how:

b = CType(arr.Item(0), Byte())

hope that helps..
Imran.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top