473,387 Members | 1,561 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,387 software developers and data experts.

Req help with Arraylist and structure not getting values back in vb.net TIA

I'm having trouble with this code...It won't loop though each value any one know why?
TIA

Public Class TestData
Public Structure Element
Dim eName As String
Dim eN1 As String
Dim eN2 As String
End Structure

End Class

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim p As New TestData.Element
Dim aList As New ArrayList

'ComboBox1.Items.Add("test")
p.eName = "000"
p.eN1 = "000 field1"
p.eN2 = "000 field2"
aList.Add(p)
p = Nothing
p.eName = "818"
p.eN1 = "818 field1"
p.eN2 = "818 field2"
aList.Add(p)
p = Nothing
p.eName = "616"
p.eN1 = "616 field1"
p.eN2 = "616 field2"
aList.Add(p)
p = Nothing
Dim i As Integer

For i = 0 To aList.Count - 1

'ComboBox1.Items.Add(p.eName)
Debug.WriteLine(String.Format( _
"alist holds {0} ele.", aList(i)))
Next

End Sub
Nov 21 '05 #1
1 941

<m@simple.net> wrote in message
news:aX*******************@bignews4.bellsouth.net. ..
I'm having trouble with this code...It won't loop though each value any
one know why?
TIA

Public Class TestData
Public Structure Element
Dim eName As String
Dim eN1 As String
Dim eN2 As String
End Structure

End Class

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim p As New TestData.Element
Dim aList As New ArrayList

'ComboBox1.Items.Add("test")
p.eName = "000"
p.eN1 = "000 field1"
p.eN2 = "000 field2"
aList.Add(p)
p = Nothing
p.eName = "818"
p.eN1 = "818 field1"
p.eN2 = "818 field2"
aList.Add(p)
p = Nothing
p.eName = "616"
p.eN1 = "616 field1"
p.eN2 = "616 field2"
aList.Add(p)
p = Nothing
Dim i As Integer

For i = 0 To aList.Count - 1

'ComboBox1.Items.Add(p.eName)
Debug.WriteLine(String.Format( _
"alist holds {0} ele.", aList(i)))
Next

End Sub


I am not sure exactly what you mean by not being able to loop through each
value. If you want to load your combo box with p.eName you can access it
like the following example.

Debug.WriteLine(String.Format("alist holds {0} ele.", CType(aList(i),
TestData.Element).eName))

Try that instead inside of your for loop. If I am missing something let
me know. I might not have understood what the problem is.

jjardine
Nov 21 '05 #2

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

Similar topics

0
by: Norm Wong | last post by:
If anyone is interested in using db2uext2 with Cygwin gcc compiler on Windows, I've modified the IBM provided sample with the attached file. There are two main modifications. The mkdir command...
9
by: Leon | last post by:
I have a webform in which when the user press generate button the form generate six unique ramdon numbers, the user can also type these six numbers in manually in any order. however, the user can...
6
by: gane kol | last post by:
Hi, I have a code that creates a datatable from an arraylist, but i am getting an error in casting in for (int intRow = 0; intRow < alLCPlist.Count; intRow++) { DataRow drow =...
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...
2
by: sal | last post by:
Greetings All I'm learning to use arraylist and structures but I'm getting a System.NullReferenceException Error and I'm not sure why. I followed the VB.net book all I did was change the names....
4
by: dotnetnoob | last post by:
i have a arraylist that look like this item 0 - hold this value 1,2,4 item 1 - hold this value 3,6,7 if i want to access the item 0 i get the whole 1,2,4 how do i seperate them out like i...
8
by: | last post by:
I have a simple structure for example purposes I add to an array list public structure MyStruct dim counter as integer end structure dim mylist as ArrayList dim x as New MyStruct ...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.