-
Jun 21st, 2015, 02:29 AM
#1
Thread Starter
Junior Member
[RESOLVED] array names algorithm
I need to write an algorithm that can automatically read a string into up to 50 arrays. The name of each array is valuearray followed by the array number i.e. the 3rd array would be valuearray3()
What i want to be able to do is write an alogrithm that reads the contents into each array without having to declare each array i.e.
Dim valuearray1() as string = text
Dim valuearray2() as string = text
Dim valuearray3() as string = text
...
Dim valuearray50() as string = text
What i want is an algorithm that functions something like this:
declarations
Dim text As String = "String"
Dim arrayindex As Intger
Dim index As Integer
Algorithm
For index = 1 To 50
"valuearray" + index + "(1)" = text
arrayindex += 1
Next index
This algorithm would add the text "string" into the first index of each array from valuearray1 to valuearray50
the only problem is that i don't know how code it in VB. It's be appreciated if you could help
Last edited by BumpaPumpa; Jun 21st, 2015 at 02:33 AM.
-
Jun 21st, 2015, 02:46 AM
#2
Re: array names algorithm
use a List(Of List(of String))
Code:
Dim a As New List(Of List(Of String))
a.Add(New List(Of String))
a.Last.Add("a string")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 21st, 2015, 03:28 AM
#3
Thread Starter
Junior Member
Re: array names algorithm
would you mind incorporating that example into my loop?
-
Jun 21st, 2015, 03:49 AM
#4
Re: array names algorithm
although a list is a great tool most of the times and if you, Bumpa are not yet familiar with it you should certainly read up on it, i think that you are more asking for a multidimensional array.
Code:
Dim MultidimensionalArray(50, 50) As String
For iRow As Int32 = 0 To MultidimensionalArray.GetUpperBound(0)
For iCol As Int32 = 0 To MultidimensionalArray.GetUpperBound(1)
MultidimensionalArray(iRow, iCol) = String.Format("row {0}, column {1}", iRow, iCol)
Next
Next
-
Jun 21st, 2015, 04:04 AM
#5
Thread Starter
Junior Member
Re: array names algorithm
Thanks! that was exactly what i was looking for.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|