I am looking for a "safe" way to compare a number with an array full of numbers.
The problem with my example is that we are searching a string, so if toSearch is for examle 31, then it will say "found" because it contains a 1. Same for 21 etc..Code:Sub CheckSomething Dim levelArray(5) As String Dim toSearch As String levelArray(0) = 1 levelArray(1) = 2 levelArray(2) = 3 levelArray(3) = 10 levelArray(4) = 12 toSearch = 31 If InStr(Join(levelArray), toSearch) > 0 Then MsgBox ("Found " & toSearch) End If End Sub
What I am looking for is a way to search the exact number in my array and not just showing "found" because the 1 in in the number 31.
Maybe you could be so nice and post a working example to compare exact numbers as this will be very helpful to me. Also, if there is a better was to create an array, feel free to let me know so I can optimize the code. I come from the PHP corner and it'smuch easier to do with php