Bug when searching through string Keys in Xojo.Core.Dictionary?

Unless I’m doing something wrong, I want to remove some keys in a dictionary based on what the key contains.

Here’s some sample code to reproduce my error:

[code]Dim d As Xojo.Core.Dictionary = New Xojo.Core.Dictionary
Dim keyString As String

Dim drop As String = “Dropdown”

d.value(drop)=drop
d.value(“new”)=“new”
For Each k As Xojo.Core.DictionaryEntry In d
keyString = CType(k.key,String)
If keyString.InStr(0,“Drop”) >=0 Then //this always = true //not good.
System.DebugLog("Key found!: " + keystring)
End If
Next[/code]

Something happening when the Auto(key value) is converted back to a string?

I’m using Windows 10 Xojo 2018 R1.1

http://documentation.xojo.com/index.php/InStr

0 means not found, so there is no way your evaluation will ever be false.

Thanks. I was using Text’s IndexOf which is zero indexed. Got it mixed up.