Is there a function that searches for a string in an array of strings and returns the index of the element? like instr but for arrays
Printable View
Is there a function that searches for a string in an array of strings and returns the index of the element? like instr but for arrays
How about Array.IndexOf? This will show "4" in a message box:
Code:Dim StringArray() As String = {"zero", "one", "two", "three", "four", "five", "six"}
MsgBox(Array.IndexOf(StringArray, "four"))
:D tnx
actually, it doesnt work for what I want. For example if I have a string array and I want to search for a partial search it wont work, it only looks for an exact match
so do I have to write my own func if I want to do a paritial search?
Mr. Polite,
Did you ever figure out how to do this?
Dim StringArray() As String = {"zero", "one", "two", "three", "four", "five", "six"}
MsgBox(StringArray.contains("four"))
Can't test this cause I'm not at a dev box, but that will work for a combobox so it should work for a array.
let me know if I'm right.
-Thankx
Array does not have such property contains.Quote:
Originally posted by Evad
Dim StringArray() As String = {"zero", "one", "two", "three", "four", "five", "six"}
MsgBox(StringArray.contains("four"))
Can't test this cause I'm not at a dev box, but that will work for a combobox so it should work for a array.
let me know if I'm right.
-Thankx
What is that?
maybe he meant indexof