问题
englishReasonsToGoToSecondFloor = "test" & ";" & "exam & pay" & ";" & " possible fake"
So my values may contain a & or (space) or just a single word. Each item is separated by a ";"
so the final list will look like "test;exam & pay;possible fake"
When the user selects an item from the Listbox, I want to quickly compare the selection with the words in the variable
rowValue = Trim(listboxTest.Column(1))
englishResult = InStr(rowValue, englishReasonsToGoToSecondFloor, CompareMethod.Text)
I can mouse over the rowValue and I see there is a value.
I've also tried with
englishResult = InStr(rowValue, englishReasonsToGoToSecondFloor, vbTextCompare)
Error message is "Run-time error '13'
回答1:
Check the help for InStr()
. Or here .
InStr ([start, ] string1, string2 [, compare ] )
The start argument is required if compare is specified.
So leave out the compare
argument, or supply start
.
And you have the string arguments mixed up (I need to remind myself of the correct order pretty often too).
string1 - Required. String expression being searched.
string2 - Required. String expression sought.
So you want
englishResult = InStr(1, englishReasonsToGoToSecondFloor, rowValue, vbTextCompare)
来源:https://stackoverflow.com/questions/38353529/my-instr-keeps-telling-me-its-mismatched