-
Well the InstrRev from the MSDN site was really a joke, as it was frustrating slow, and it got slower the longer strings you put into it. (as it reversed the whole string). Can anyone do another one that doesn't reverse it and still search for my string, btw, i only need one char to search for so that should be pretty easy code for you to make.
Thanks!
-
I hope this is what your after. Not perfect i know, but i know you are more than capable of changing it.
Code:
Option Explicit
Private Function myInstrRev(stString As String, stFind As String, Optional iStart As Long) As Long
Dim iCtr As Long
Dim iLen As Integer
Dim iLoopStart As Long
iLen = Len(stFind)
If iStart > 0 Then
If iStart > Len(stString) Then
iStart = Len(stString)
End If
iLoopStart = iStart
Else
iLoopStart = Len(stString)
End If
For iCtr = iLoopStart To 1 Step -1
If Mid$(stString, iCtr, iLen) = stFind Then
myInstrRev = iCtr
Exit Function
End If
Next iCtr
End Function
Private Sub Command1_Click()
MsgBox myInstrRev(Text1.Text, Text2.Text, Val(Text3.Text))
End Sub
-
Thanks IAin, saved me alot of time!:)
-
InStrRev
Could you give a very simple example how this function works? ie: i would like to extract the file name from the many exclusive paths within a file.
e:\netvespaweb\5.1.0.10\Customer\drivers\ComCtl32 5.80\50ComUpd.Exe
e:\netvespaweb\5.1.0.10\Customer\drivers\ComCtl32 5.80\ReadMe.Txt
e:\netvespaweb\5.1.0.10\Customer\drivers\DCOM v1.3 for Windows 95\dcom95.exe
e:\netvespaweb\5.1.0.10\Customer\drivers\odbc\mdac_2.1.exe
Many thanks.
-
Righty ho. To start with that InStrRev function above is crap. I have written a much better one since then.
InStrRev
To use it to get a filename.
Code:
strFileName = Right$(strFullName, Len(strFullName) - InStrRev(strFullName, "\"))
-
intrStrRev
Sorted IT, thanks for reply.