This looked like a good candidate for a FAQ!
===========================================
raskew (Programmer) Apr 1, 2002
Function xLastInStr(tstr As String, twhat As String) As Integer
'*******************************************
'Name: xLastInStr (Function)
'Purpose: Return location of last instance of a character or phrase.
'Inputs: Call xLastInStr("the quick brown fox jumped the lazy dog", "the")
'Output: 28 - Location of last occurence of "the"
'*******************************************
Dim i As Integer, n As Integer, tlen As Integer
n = 0
tlen = Len(twhat)
For i = Len(RTrim(tstr)) To 1 Step -1
If Mid(tstr, i, tlen) = twhat Then
n = i
Exit For
End If
Next i
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.