Instr Returns 0

ScottInTexas

New member
Joined
Oct 4, 2022
Messages
3
Programming Experience
5-10
This line returns false. InStr(rslt.Name, resultName, CompareMethod.Text) > 0
It should be returning true since the result of Instr should be 3. In the watch window rslt.Name = "2-Thickness" and resultName = "Thickness"
The function that this line is a part of is part of the base class and is used by a lot of classes. It is just an averaging function, so including the loop here is not necessary. I just want to know how the Instr is failing.
Until now the code has just been using two parameters, the search string and the sought string. It has worked for years like that. But today it is not returning true in this case.

Thickness.PNG

Values.PNG


If I type "Debug.Print(Instr("2-Thickness","Thickness"))" in the immediate window I get 3.
Can someone tell me what is wrong?
Thanks for seeing what I can't!
 
resultName string in your watch ends with a space.
 
Solution

Latest posts

Back
Top