In case anyone is interested / faces a similar problem, here's how I
solved it:
In the library that I use for most of my applications, I created a
"TextCompare" class in it's own source file, which is Option Compare
Text. The class consists of public shared functions that simply invoke
the "like" operator and other comparison checks that reply on "Option
Compare".
(For my other source files, I've added an explicit "Option Compare
Binary" in addition to the obligitory "Option Strict On" and "Option
Explicit On" just so it's unambigous what's happening).
Now, if I want "Compare Binary" I do the comparison the standard way.
If I want "Compare Text" (and String.Compare() isn't appropriate) I
call the TextCompare static method.
=======================================================
Option Strict On
Option Explicit On
Option Compare Text
Public Class TextCompare
Public Shared Function txtEquals(ByVal str1$, ByVal str2$) _
As Boolean
Return str1$.Equals(str2$)
End Function
Public Shared Function txtLike(ByVal str1$, ByVal pattern$) _
As Boolean
If str1$ Like pattern$ Then Return True
Return False
End Function
Public Shared Function indexOf(ByVal outerStr$, ByVal innerStr$) _
As Integer
Return outerStr$.IndexOf(innerStr$)
End Function
Public Shared Function lastIndexOf(ByVal outerStr$, ByVal
innerStr$) _
As Integer
Return outerStr$.LastIndexOf(innerStr)
End Function
Public Shared Function startsWith(ByVal outerStr$, ByVal innerStr$)
_
As Boolean
Return outerStr$.StartsWith(innerStr)
End Function
Public Shared Function endsWIth(ByVal outerStr$, ByVal innerStr$) _
As Boolean
Return outerStr$.EndsWith(innerStr)
End Function
End Class
|