VB Code:
Public Function IsGoodInBArr(Optional fLigaturesToo As Boolean) As Boolean
' verify correct InStr returns, 20021005
' returns True if all tests are passed
Dim fFailed As Boolean
Dim Temp() As Byte
Dim Test As Long
' replace ".InStr01" with the name of your function
Temp = "abc"
If InBArr(Temp, "b") <> 2 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "ab") <> 0 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "aB") <> -1 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "aB", , vbTextCompare) <> 0 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "ab", 2) <> 4 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "ab", 4) <> 4 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "ab", 6) <> -1 Then Stop: fFailed = True
Temp = "aaabcab"
If InBArr(Temp, "abc", 6) <> -1 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "", 6) <> 6 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "", 8) <> 8 Then Stop: fFailed = True
Erase Temp
If InBArr(Temp, "", 6) <> -1 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "c") <> -1 Then Stop: fFailed = True
Temp = "abcdabcd"
If InBArr(Temp, "abcd") <> 0 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "Ab") <> -1 Then Stop: fFailed = True
Temp = "abab"
If InBArr(Temp, "Ab", , vbTextCompare) <> 0 Then Stop: fFailed = True
Temp = "a" & String$(50000, "b")
If InBArr(Temp, "a") <> 0 Then Stop: fFailed = True
' unicode
Temp = "a€€c"
If InBArr(Temp, "€") <> 2 Then Stop: fFailed = True
' the 4 stooges: š/Š, œ/Œ, ž/Ž, ÿ/Ÿ (154/138, 156/140, 158/142, 255/159)
Temp = "Hašiš"
If InBArr(Temp, "Š", , vbTextCompare) <> 4 Then Stop: fFailed = True
' ligatures textcompare (VBspeed entries do NOT have to pass this test)
If fLigaturesToo Then
' ligatures, a digraphemic fun house: ss/ß, ae/æ, oe/œ, th/þ
Temp = "Straße"
If InBArr(Temp, "ss", , vbTextCompare) <> 8 Then Stop: fFailed = True
End If
' well done
IsGoodInBArr = Not fFailed
End Function