473,327 Members | 2,118 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,327 software developers and data experts.

Update Element in ArrayList Structure

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
Nov 21 '05 #1
8 6545
On 2005-06-26, wg <wg@hotmail.com> wrote:
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.

--
Tom Shelton [MVP]
Nov 21 '05 #2
Hi,

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

Ken
-----------------
"wg" <wg@hotmail.com> wrote in message
news:oR****************@bignews4.bellsouth.net...
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

Nov 21 '05 #3
WG,

You know that with OleDb you can in one time from a CSV make a dataset?

See this sample on our site
http://www.windowsformsdatagridhelp....f-212f9e0de193

I hope this helps,

Cor
Nov 21 '05 #4
"wg" <wg@hotmail.com> schrieb
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

Nov 21 '05 #5
"Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb
Directcast(arraylist.item(number), YourStructureName).value =
NewValue


Doesn't work because the returned value is a value type.

Armin
Nov 21 '05 #6
"Armin Zingler" <az*******@freenet.de> schrieb:
Directcast(arraylist.item(number), YourStructureName).value =
NewValue


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 ;-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
wg
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
"wg" <wg@hotmail.com> wrote in message
news:oR****************@bignews4.bellsouth.net...
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

Nov 21 '05 #8
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?
--
Dennis in Houston
"Cor Ligthert" wrote:
WG,

You know that with OleDb you can in one time from a CSV make a dataset?

See this sample on our site
http://www.windowsformsdatagridhelp....f-212f9e0de193

I hope this helps,

Cor

Nov 21 '05 #9

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

Similar topics

7
by: Adam | last post by:
Hi all, In my VB.NET code below, I try to change the user name in my arraylist from Ted to Bob, but instead it adds a new user to the arraylist named Bob. Can anyone explain why this happens and...
12
by: Sueffel | last post by:
I'm having problems with this one: I have a tructure that is being added to an arraylist, so I may have 15 of these structure objects in an arraylist. now, what I want to do is this: dim TT as...
3
by: Sam | last post by:
Hi Everyone, I have a stucture below stored in an arraylist and I want to check user's input (point x,y) to make sure there is no duplicate point x,y entered (string label can be duplicated). Is...
8
by: Maileen | last post by:
Hi, I would like to have something like an array (something like a collection) in order to store the following things : company name1, new1, old1, in1, out1 company name2, new2, old2, in2,...
1
by: Joe | last post by:
Hello All: I am writing a function which accepts an ArrayList as its parameter and converts the contents of the ArrayList into an XmlNodeList. The ArrayList will contain one of several...
18
by: Sam | last post by:
Hi All I'm planing to write an application which allows users dynamically add their points (say you can add upto 30,000) and then draw xy graph. Should I use an array for my coordinate point...
1
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections...
1
by: nickpay | last post by:
Hello, I've trawled through many of the postings on this site but am still unable to find the right solution to removing the XML tag that is created when Serializing using an ArrayList. The...
12
by: Justin | last post by:
Ok, I give up. I can't seem to construct a decent (productive) way of sorting my arraylist. I have a structure of two elements: Structure TabStructure Dim TabName As String Dim FullFilePath...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.