Array with no bounds (1 Viewer)

k0r54

Registered User.
Local time
Today, 04:21
Joined
Sep 26, 2005
Messages
94
Hi,

Is there a way i can create an array with no bound like so (FieldSep being the array) -
Code:
    Do
      pnt = InStr(stp, ary, " ") - 1
      FieldSep(cnt) = Array(pnt, fmt)
      stp = pnt + 2
      cnt = cnt + 1
    Loop While InStr(stp, ary, " ") <> 0 Or stp > Len(ary)

The problem i get is i need to declare it i.e
Code:
Dim FieldSep(100) as string

which mean if i cnt is less than 100 it puts everything as default and if cnt is more than 100 it fails as script out of range. How can i just let it keep adding to itself so i dont have to declare how bit it is. It just does it itself

Thanks
k0r54
 

Bodisathva

Registered User.
Local time
Yesterday, 23:21
Joined
Oct 4, 2005
Messages
1,274
use the ReDim statement to change the upper bound and the Preserve keyword to insure that the original data is maintained while being redimensioned...which, by the by, in multi-dimensional arrays can only be the last dimension:

Code:
Dim arrayX(25,35,100) as Integer
...
...
...
ReDim Preserve arrayX(25,35,75)
 

k0r54

Registered User.
Local time
Today, 04:21
Joined
Sep 26, 2005
Messages
94
sorry, im a bit confussed?

why is there 25,35,75 ?

Also the number of arrays will vary?

Thanks
k0r54
 
Last edited:

k0r54

Registered User.
Local time
Today, 04:21
Joined
Sep 26, 2005
Messages
94
Ahhh i have done it

I done
ReDim FieldSep(100)

then after the loop done
ReDim preserve FieldSep(cnt - 1)

Thanks
k0r54
 

Users who are viewing this thread

Top Bottom