|
Search an array
'search for first occurrence of TestValue in MyArray
'if you know the upper/lower limits of the array, just use them
'TestValue and MyArray should have the same type
Dim
TestValue
As
String
TestValue
=
"searchstring"
For
i
=
Lbound
(MyArray)
To
Ubound
(MyArray)
If
MyArray(i)
=
TestValue
Then
'value found, do something
Exit
For
'stop searching
End If
next
i
'search all elements of MyArray for TestValue
'if you know the upper/lower limits of the array, just use them
'TestValue and MyArray should have the same type
Dim
TestValue
As
String
TestValue
=
"searchstring"
For
i
=
Lbound
(MyArray)
To
Ubound
(MyArray)
If
MyArray(i)
=
TestValue
Then
'value found, do something, then continue searching
End If
next
i
|