Update Element in ArrayList Structure

  • Thread starter Thread starter wg
  • Start date Start date
W

wg

I have worked on this for a while and have not been able to get it working.
I seem to be missing something. What I am attempting to do is get
information from a csv file such as: name (stirng), unit number (int),
address (int), value (int), etc. I created a structre to handle each
element. Since there is an unknown number of rows I have used an arraylist
to hold it. This works using the arraylist.add(structure).

The problem is that after loading I get information from an external device
tied to the serial port. As this information is recieved I would like to
update the value element in the arraylist. I did this in VB6 by using a UDT
the dynamic arrays. I have read that this should not be done in VB.NET, to
use the arraylist instead.


Any help would be greatly appriciated.

Thanks

wg
 
I have worked on this for a while and have not been able to get it working.
I seem to be missing something. What I am attempting to do is get
information from a csv file such as: name (stirng), unit number (int),
address (int), value (int), etc. I created a structre to handle each
element. Since there is an unknown number of rows I have used an arraylist
to hold it. This works using the arraylist.add(structure).

The problem is that after loading I get information from an external device
tied to the serial port. As this information is recieved I would like to
update the value element in the arraylist. I did this in VB6 by using a UDT
the dynamic arrays. I have read that this should not be done in VB.NET, to
use the arraylist instead.


Any help would be greatly appriciated.

Thanks

wg

wg... use a class in an arraylist. Using a structure can be made to
work, but it is very inefficent.
 
Hi,

Directcast(arraylist.item(number), YourStructureName).value = NewValue

Ken
-----------------
I have worked on this for a while and have not been able to get it working.
I seem to be missing something. What I am attempting to do is get
information from a csv file such as: name (stirng), unit number (int),
address (int), value (int), etc. I created a structre to handle each
element. Since there is an unknown number of rows I have used an arraylist
to hold it. This works using the arraylist.add(structure).

The problem is that after loading I get information from an external device
tied to the serial port. As this information is recieved I would like to
update the value element in the arraylist. I did this in VB6 by using a UDT
the dynamic arrays. I have read that this should not be done in VB.NET, to
use the arraylist instead.


Any help would be greatly appriciated.

Thanks

wg
 
wg said:
I have worked on this for a while and have not been able to get it
working. I seem to be missing something. What I am attempting to do
is get information from a csv file such as: name (stirng), unit
number (int), address (int), value (int), etc. I created a structre
to handle each element. Since there is an unknown number of rows I
have used an arraylist to hold it. This works using the
arraylist.add(structure).

The problem is that after loading I get information from an external
device tied to the serial port. As this information is recieved I
would like to update the value element in the arraylist. I did this
in VB6 by using a UDT the dynamic arrays. I have read that this
should not be done in VB.NET, to use the arraylist instead.


Value types added to an arraylist can not be changed. Retrieving the Item
always retruns a copy because it's a value type. As Tom wrote, use a class
instead.

Armin
 
Armin Zingler said:
Doesn't work because the returned value is a value type.

You'll have to reassign the value to the item after changingt the copy, or
use a class instead of the structure ;-).
 
I have attempted to use a class in the beginning but could never get it to
work right. Could someone give a quick example?


Thanks

wg
 
Thanks for the tip Cor. I assume the row delimiter is a \ or can be anything
that the FMT=Delimited* is set to like the *. Is this correct?
 

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

Back
Top