473,378 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

problem with byte array in an arraylist

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.
Nov 21 '05 #1
2 1753
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.
"Saurabh Kumar" <au@sd.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 21 '05 #2
thanks!

"Imran Koradia" <no****@microsoft.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
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.
"Saurabh Kumar" <au@sd.com> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl...
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.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
1
by: Paul Fi | last post by:
I have this client code: string server = "localhost"; int port = 8085; IPHostEntry hostent = Dns.Resolve(server); IPAddress hostadd = hostent.AddressList; IPEndPoint EPhost = new...
19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
6
by: Petar Popara | last post by:
I need some help converting byte into Array: int bufferLen = Convert.ToInt32(file.Length); byte buffer = new byte; int len = sr.Read(buffer, 0, bufferLen); ArrayList a = new ArrayList(len);...
6
by: Dennis | last post by:
I was trying to determine the fastest way to build a byte array from components where the size of the individual components varied depending on the user's input. I tried three classes I built: (1)...
32
by: Guoqi Zheng | last post by:
I am really do not know so much about byte/bit, etc. Question, if I defined a byte(), how can I add a single byte to it? what I want is that I have an array of bytes, I loop that array, look at...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have the following problem in my client-server Application My server take array and serialize it into the memorystream Dim ns As NetworkStream = client.GetStream() Dim writer...
0
by: Sektor | last post by:
Hi guys, I have just a problem with the Select timeout parameter. The MSDN tells us: microSeconds The time-out value, in microseconds. A -1 value indicates an infinite time-out. I try to use...
2
by: Rene Sørensen | last post by:
I'm using .NET 2.0 VS 2005 I'm creating a function that dos something similar to the. SmoApplication.EnumAvailableSqlServers() function. But for som resone I get an error or do i?. The problem...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.