473,944 Members | 7,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(s tructure).

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 6638
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(s tructure).

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(arra ylist.item(numb er), YourStructureNa me).value = NewValue

Ken
-----------------
"wg" <wg@hotmail.com > wrote in message
news:oR******** ********@bignew s4.bellsouth.ne t...
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(s tructure).

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(s tructure).

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***@bellsout h.net> schrieb
Directcast(arra ylist.item(numb er), YourStructureNa me).value =
NewValue


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

Armin
Nov 21 '05 #6
"Armin Zingler" <az*******@free net.de> schrieb:
Directcast(arra ylist.item(numb er), YourStructureNa me).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******** ********@bignew s4.bellsouth.ne t...
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(s tructure).

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
2101
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 how I might modify a structure in an arraylist without having to completely remove it and re-add the structure to the arraylist? I just want to iterate throught the arraylist and change items based on certain conditions. Thanks in advance!
12
2139
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 MyStruct = New MyStruct TT = MyArraylist.Item(3) I have even tried this:
3
2306
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 there a way to compare the new input point x,y without having to a loop and compare the whole object in the array list. I can't use the indexof method because it would compare the whole object. Public Structure
8
1501
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, out2 .... but i should be able to dynamically redimension it.
1
1748
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 different structures. For example, the structures could be either a Customer structure (which contains a customer id and name) or an Address structure (which contains an address type and street number, city, etc). The XmlNodeList is uded to populate a...
18
3270
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 storage and dynamically resize it when there is a new point or should I use ArrayList? Is speed noticable between the two? Regards,
1
8727
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 Framework are said to have an element type. http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
1
1509
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 structure that I'm trying to create is as follows : <RootNode> <Detail_level1>some attributes go here</Detail_level1> <Series> <Programme>details of the programme go here</Programme> <Programme>details of the...
12
9813
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 As String End Structure
0
10145
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9971
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11134
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11307
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6313
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4920
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4516
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.