Defining arrays in terms of a variable

Hi, my problem is with defining arrays in terms of another variable, in other words the size of the array is stored in a variable. here is the code and the error message. Note that in my program this variable will not change and the array will only to be defined once.

Dim a As Integer
a = filedir.ListCount '"filedir" is a filelistbox on my form
Dim file(a) As String 'this line is highlighted when debugging

error message: Compile error: Constant expression required

once i write dim file(75) i dont receive the error and i can fill the array with the lines from my filelistbox with no problems, each array element being a filelistbox item.

Is what im doing not possible in VB6 or can i use other methods to create data structers Im using Visual basic 6 on WIndows XP Professional.



Answer this question

Defining arrays in terms of a variable