initialising values in an array

  • Thread starter Thread starter Kay
  • Start date Start date
K

Kay

Hello,

I declare an array as follows

Dim returnArray() as boolean

I need to initialise the values of the array at runtime, I am calling a
function multiple times, that return a boolean value and I am using the
returned values to fill the array. I have tried the following but get an
error

returnArray(index) = functionWhichReturnsABoolean()

how do I set the array elements at runtime to be the returned value?

Any suggestions appreciated.
Thanks,
Kay.
 
What error are you getting? If that there is all your code working with the
array creation/setup, then what the problem would be is that you declared
the array as an empty array with no dimiension and are trying to add an
element 0, or 1 when there is no such element.
You need to give your array a size to be able to put anything into it:
Dim returnArray(5) As Boolean

Or you could use array initialization...
Dim returnArray() As Boolean = { _
firstFunctionCall(), _
secondFunctionCall(), _
thirdFunctionCall() _
}
 
Back
Top