I have say:
C:\blah\foo\bar.txt
I need just bar.txt...
I see InStr returns first occurence..I probably need last occurence?
Jon
Printable View
I have say:
C:\blah\foo\bar.txt
I need just bar.txt...
I see InStr returns first occurence..I probably need last occurence?
Jon
Use InStrRev() to get last occurence of backslash and then Mid(... pos +1):
VB Code:
Private Sub Command1_Click() Dim sText$ sText = "C:\blah\foo\bar.txt" MsgBox Mid(sText, InStrRev(sText, "\") + 1) End Sub
or...
VB Code:
Dim sText$ Dim strParts() As String sText = "C:\blah\foo\bar.txt" strParts = Split(sText, "\") MsgBox strParts(UBound(strParts))