Strip File Name From Full Path

'Insert the following code to your form:

Function StripPath(T$) As String
Dim x%, ct%
StripPath$ = T$
x% = InStr(T$, "\")
Do While x%
ct% = x%
x% = InStr(ct% + 1, T$, "\")
Loop
If ct% > 0 Then StripPath$ = Mid$(T$, ct% + 1)
End Function

Private Sub Form_Load()
'Enter here the full path you want to strip from it the file name.
MsgBox StripPath("c:\mydir\myfile.exe")
End Sub

Go Back