01-26-2004, 08:36 PM
* Guru *
Join Date: Jun 2003
Location: Upstate New York, usa
If you just want to see if the index exist, then you can check to if the
index >= lbound(array) And index <= ubound(array) as GavinO meant to
do (I often reverse my > and < myself if I don't check myself, don't know why).
Passing the array as a variant, also seems to work. I don't know if this
is what you meant by "exist".
Dim B(1 To 20) As Integer
Private Function ElementExists(A As Variant, Index As Integer) As Boolean
If Index >= LBound(A) And Index <= UBound(A) Then
ElementExists = True
ElementExists = False
Private Sub Command1_Click()
Print ElementExists(B, 15)
Print ElementExists(B, 30)
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.