I'm learning VB, how can I declare and use arrays of variables.
Thanx
Printable View
I'm learning VB, how can I declare and use arrays of variables.
Thanx
There is more than one way.
1st way - define top boundary
2nd way - define index rangesCode:Dim vsMyStrings(5) as String
vsMyStrings(0) = "First String"
vsMyStrings(5) = "Last String"
Code:Dim vsMyStrings(5 to 9) as String
vsMyStrings(5) = "A string"
vsMyStrings(9) = "Another string"
Code:Dim iArray(4) As Integer
iArray(0) = 1
iArray(1) = 2
iArray(2) = 3
iArray(3) = 4
iArray(4) = 5
'etc.
Thanx parksie
ReDim Preserve MyArray ..... way cool enhancement to vb5.
Also you might like to have a look at multi-dimension arrays
Cool if you want to hold in memory something like a number of CDs with the tracks on each cd.:)Code:
Dim MyArray(4,4).
For X = 0 to 4
For Y = 0 to 4
MyArray(X,Y) = whatever
Next Y
Next x
Hope that gives you some more pointers
There is an array tutorial which goes into some detail on this site.
http://www.vb-world.net/articles/arrays/