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

Question: arraylist and item

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 want "1" how do i access item 0 but the first value "1".

thank
Jul 25 '06 #1
4 1108
so you have a variable you want to hold like 1,5,7? try a multi-demensional
arry
Private arrNumbers(,) As Integer = {{5, 6, 6}, _
{8, 9, 10}}

hope that helps
--
-iwdu15
Jul 25 '06 #2

dotnetnoob wrote:
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 want "1" how do i access item 0 but the first value "1".

thank
Well... The only way really to do that is to store this as either an
arraylist of arraylists, or an arraylist of arrays. I would suggest
the latter if the individual elements are fixed length. Then you could
do something like (Assuming 2003 - if your useing 2005, then you could
improve the following using generics):

Option Strict On
Option Explicit On

Imports System
Imports System.Collections

Module Module1

Sub Main()
Dim list As New ArrayList

list.Add(New Integer() {1, 2, 3})
list.Add(New Integer() {5, 6, 7})
list.Add(New Integer() {7, 15, 25})
list.Add(New Integer() {8, 27, 10})

Console.WriteLine(DirectCast(list(3), Integer())(1))

End Sub

End Module

The above prints 27.

--
Tom Shelton [MVP]

Jul 25 '06 #3
it's not exactly what i'm looking for but i got it. basically, i'm going to
treate it as string and get the character out of the string in the arraylist

"iwdu15" wrote:
so you have a variable you want to hold like 1,5,7? try a multi-demensional
arry
Private arrNumbers(,) As Integer = {{5, 6, 6}, _
{8, 9, 10}}

hope that helps
--
-iwdu15
Jul 25 '06 #4
dotnetnoob wrote:
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 want "1" how do i access item 0 but the first value "1".

thank
You could do this several ways. One option is to create a structure and
use that for your items:

--------------------------------
Public Structure DataItem
Dim value1 as Integer
Dim value2 as Integer
Dim value3 as Integer
End Structure
--------------------------------

For each item that you have, you could create a new DataItem and assign
the values appropriately. Using the values from your example above:

--------------------------------
Dim newItem as new DataItem
newItem.value1 = 1
newItem.value2 = 2
newItem.value3 = 4
--------------------------------

After you've created DataItems for all of the data, you could put them
into an array of type DataItem like so:

--------------------------------------------------
Dim DataItems as DataItem() = {var1,var2,var3,...}
--------------------------------------------------

or add them to an ArrayList. If you use an arraylist, you'll most
likely have to cast the object to type DataItem to access the
..value1,.value2,.value3 items.

A structure is a simple form, you could always create a class to hold
the data, and instantiate the values in a constructor.

Hope this Helps
Jul 28 '06 #5

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

Similar topics

4
by: Stephen | last post by:
I have got an event below to remove items from an arraylist and then to rebind the arraylist to the datagrid subsequently deleting the appropriate row. My problem is that my code makes sense and I...
2
by: Stephen | last post by:
I am trying to delete a row in a datagrid on the onclick of a asp:ButtonColumn. The datagrid is created from the items in an arraylist so what im trying to do is remove the item from the array and...
2
by: keys4worship | last post by:
I am populating an arraylist from a text file on my PC. I am using this information with C# to perform actions against a PCOM session. A for loop handles the actions to perform. If for some reason...
10
by: C Downey | last post by:
Hello: I have an arraylist storing some very basic objects. The object is very basic, it has 2 properties : ID, and COUNT Before I add an object to the arraylist, I want to check if an...
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...
20
by: Dennis | last post by:
I use the following code for a strongly typed arraylist and it works great. However, I was wondering if this is the proper way to do it. I realize that if I want to implement sorting of the...
7
by: J L | last post by:
I have defined a structure private structure FieldInfo dim FieldName as string dim OrdinalPostioin as Integer dim DataType as Type dim Size as Integer end structure I read this information...
9
by: me | last post by:
Hi All, I am new to Classes and learniing the ropes with VB.NET express Here's my question - say I have a want to manage a list of books. Each book has an Author, Title and ISBN Now, I am...
1
by: dotnetnoob | last post by:
let's say i have a arraylist that contain 1 1 0 1 this arraylist serve as a flag if the value inside the arraylist is 1 then that mean it's on and if it's 0 then it's off so i got this code ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.