How to extract the filename from a variable

1 post / 0 new
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57
How to extract the filename from a variable

Here is a way to extract the filename from a variable that contains the path and filename.

Sub Main

strFilePath = "C:\folder\folder\folder\file.txt"

MsgBox Mid(strFilePath, Len(strFilePath) - InStr(1, iReverse(strFilePath), "\") + 2, InStr(1, iReverse(strFilePath), "\") - 1)


End Sub