Is there something like indexOf() for an array in VBA 2003?
Is there something like len() to get the length of an array?
I need to get the index of an element in array, and the length of the array. Any solution is appreciated.
Is there something like indexOf() for an array in VBA 2003?
Is there something like len() to get the length of an array?
I need to get the index of an element in array, and the length of the array. Any solution is appreciated.
To get the Index you will need to loop.
[VBA] For i = LBound(MyArray) To UBound(MyArray)
If MyArray(i) = "ThisValue" Then
Index = i
Exit For
End If
Next i
Msgbox Index
[/VBA]
For length of the array do you mean the number of items or the actual total length of all items. For the first on just use UBound, for the second, loop and add up the Len of each item.
Thank you very much DRJ. Your timely answer solved my problem. I was looking for something like indexOf(). When I could not find it, I tried to implement one myself. Then I could not find something like len(). Now I see that actually, UBound() is the answer.