If "a"="A" being true?

I have the following code:

var filter As String
if filter=“A” then
exit do 'outer loop
end if

When filter is actually “a” this is still being evaluated as TRUE. I have even tried using string.contains. Where am I going wrong on this? I found a workaround. But still would like to know.

The string is coming from a saved text file, not binary.


String comparisons, in most cases, are case insensitive. If you want to check equality with case sensitivity, use String.Compare. Or RegEx.


1 Like

a and A have a different character code/no/id.

I have even tried using string.contains

see ComparisonOptions for .Contains
searchString As String, options As ComparisonOptions = ComparisonOptions.CaseInsensitive, locale As Locale = Nil

if you not like regex
you could compare with upper case

If StringA.Upper = StringB.Upper
If StringA.Lower = StringB.Lower

You could just use the ASC() function to return the ASCII code and from there determine if it’s Upper or Lower Case since the value for a Lowercase Letter is different than the Uppercase.

This will work with one-character strings, of course.