|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Update Element in ArrayList StructureI 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 On 2005-06-26, wg <w*@hotmail.com> wrote:
Show quoteHide quote > I have worked on this for a while and have not been able to get it working. wg... use a class in an arraylist. Using a structure can be made to> 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 work, but it is very inefficent. -- Tom Shelton [MVP] Hi,
Directcast(arraylist.item(number), YourStructureName).value = NewValue Ken ----------------- "wg" <w*@hotmail.com> wrote in message I have worked on this for a while and have not been able to get it working.news:oRmve.3267$wm.1578@bignews4.bellsouth.net... 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 "Ken Tucker [MVP]" <vb***@bellsouth.net> schrieb Doesn't work because the returned value is a value type.> Directcast(arraylist.item(number), YourStructureName).value = > NewValue Armin "Armin Zingler" <az.nospam@freenet.de> schrieb: You'll have to reassign the value to the item after changingt the copy, or >> Directcast(arraylist.item(number), YourStructureName).value = >> NewValue > > Doesn't work because the returned value is a value type. 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/> 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.info/default.aspx?ID=1b644f6b-aa01-49f6-bc1f-212f9e0de193 I hope this helps, Cor 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? -- Show quoteHide quoteDennis 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.info/default.aspx?ID=1b644f6b-aa01-49f6-bc1f-212f9e0de193 > > I hope this helps, > > Cor > > >
Show quote
Hide quote
"wg" <w*@hotmail.com> schrieb Value types added to an arraylist can not be changed. Retrieving the Item> 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. always retruns a copy because it's a value type. As Tom wrote, use a class instead. Armin 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 Show quoteHide quote "wg" <w*@hotmail.com> wrote in message news:oRmve.3267$wm.1578@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 >
VS Pro 2005 vis a vis VSTO 2005
Multi Forms Protecting against type mismatch errors Information on command line arguments and more fun stuff. Add record to Access Databases Q: Status Bar Vanishes Add record to Access Database imports\namespace question Using JPG stills to make a "Video" file Public vs Shared |
|||||||||||||||||||||||