Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Infinite Array 1

Status
Not open for further replies.

suoirotciv

Programmer
Dec 3, 2002
205
PH
Hey guys!!!

Is it possible in VB that I can declare an infinite array???

Please pardon the grammar.
Not good in english.
 
You can define a dynamic array as follows:

Dim lngIndex As Long
Dim avarArray As Variant

'One dimension array

'Initialize empty array - ZERO based
Redim avarArray(lngIndex)

'Spin through data preserving prior values
Redim Preserve avarArray(lngIndex)
avarArray(lngIndex) = SomeValue
lngIndex = lngIndex + 1

'Later retrieve the data
For lngIndex = 0 to UBound(avarArray)
Msgbox avarArray(lngIndex)
Next lngIndex

'Multiple dimension array

Redim avarArray(3, lngIndex) '4 by 1 multi dimension

'Spin through data preserving prior values
Redim Preserve avarArray(3, lngIndex)
avarArray(0, lngIndex) = SomeValue1
avarArray(1, lngIndex) = SomeValue2
avarArray(2, lngIndex) = SomeValue3
avarArray(3, lngIndex) = SomeValue4
lngIndex = lngIndex + 1

'Later retrieve the data
For lngIndex = 0 to UBound(avarArray, 2)
Msgbox "Value1: " & avarArray(0, lngIndex) & vbcrlf _
& "Value2: " & avarArray(1, lngIndex) & vbcrlf _
& "Value3: " & avarArray(2, lngIndex) & vbcrlf _
& "Value4: " & avarArray(3, lngIndex)
Next lngIndex

Good Luck!

Have a great day!

j2consulting@yahoo.com
 
okay then . . . thanks for your quick response . . . but actually i'm not the one that really needs this but my friend . . so i'm still going to pass it to him . . . and i'll get back here if this works for him . . .

again thank you . . .

Please pardon the grammar.
Not good in english.
 
Collections can be regarded as an infinite array.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
hey thanks a lot . . . this is what he's looking for . . .

Please pardon the grammar.
Not good in english.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top