Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find "R" (not "r") in string

Status
Not open for further replies.

fmientjes

Programmer
Joined
Mar 27, 2002
Messages
55
Location
NL
I want to search a string for the "R" only, (so lowercase ("r") is not valid).

So I hoped the Instr function would do the trick, but it doesn't. There is no difference between R and r.
And I can not search voor the ascii value (Asc("R")=82); I cannot get the instr to work with that.

Can anyone help me out?

Thanks,
Frans

 
Are you using the compare parameter with InStr?
Code:
'-- Compare these two calls to the function:
target="Mixed Case"
?InStr(1, target, "c", 0)
?InStr(1, target, "c", 1)

Geoff Franklin
 
Thanks, it give me hint to make the follwing function:
Public Function CheckCombinatie(strCombinatie As String, Optional strReferentie As String) As String


Dim i As Integer
Dim iAantalLetters As Integer
Dim ascCombinatie As Integer

ascCombinatie = Asc(strCombinatie)
iAantalLetters = Len(strReferentie)
CheckCombinatie = "Nee"

If IsEmpty(Trim(strReferentie)) = True Then
Exit Function
End If

For i = 1 To iAantalLetters
If Mid(strReferentie, i, 1) = strCombinatie Then
If Asc(Mid(strReferentie, i, 1)) = ascCombinatie Then 'Combinatie gevonden (case sensitive)
'Found it!
End If
End If
Next i


End Function
 
a binary compare should handle the case differences
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top