|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Question: arraylist and itemi 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 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 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 Show quoteHide quote "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 dotnetnoob wrote:
> i have a arraylist that look like this Well... The only way really to do that is to store this as either an> > 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 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] dotnetnoob wrote:
> i have a arraylist that look like this You could do this several ways. One option is to create a structure and > > 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 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
RegEx Either Or
Newbie question - VB.net, referencing controls Discrepancy in DataGridView column order & databound DataTable Icon.FromHandle(..) not working? Lauch VB.NET App From Network Drive Or Network Share. how to hardcode lots of text into a textbox/RichTextbox? Need help/advice to make a decision positioning a watermark on a web page regardless of screen size Any way to pass an optional array? ToolStripComboBox .Width < 75? |
|||||||||||||||||||||||