PDA

View Full Version : [SOLVED] Determing Array Size



MWE
05-29-2005, 06:37 PM
Is there a way to dynamically determine the size of an array. In particular, assume that the parent proc has dimensioned an array, X, at 5, e.g.,


Dim X(5) as Single


The parent then calls SubA and passes X as one of the arguements. Is there a way for SubA to "figure out" the size of X so that if the # of values to be stuffed in X exceeds the original dimension, SubA would stop and perhaps display an error message.

Solutions already considered:
1. pass the length of X to SubA
2. trap the error in SubA, e.g., On Error ...

johnske
05-29-2005, 07:12 PM
Sub DoThis()
Dim MyArray(1 To 20) As Long
MsgBox "MyArray is " & LBound(MyArray) & " to " & UBound(MyArray)
End Sub

MWE
05-29-2005, 07:18 PM
Sub DoThis()
Dim MyArray(1 To 20) As Long
MsgBox "MyArray is " & LBound(MyArray) & " to " & UBound(MyArray)
End Sub



Thanks. This seems almost too easy; but it works

johnske
05-29-2005, 07:25 PM
Thanks. This seems almost too easy; but it works

It was - It does. Have a nyce day :thumb