Hi, if you check the exact string String not sub-String in the array, use StrComb, because if you use InStr, then if array = "apple1", "apple2", "apple3", "apple" and choice = "apple", then everyone will return pass for each element of the array.
Function CompareStrings ( arrayItems , choice )
For i=Lbound(arrayItems) to Ubound(arrayItems)
' 1 - for binary comparison "Case sensitive
' 0 - not case sensitive
If StrComp(arrayItems(i), choice , 1) = 0 Then
CompareStrings = True
MsgBox("Found " & choice & " at index " & i
Else
CompareStrings = False
MsgBox "String not found!"
End If
Next
End Function
source
share