by D. de Haas (4 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (40 Votes)
It extracts a filename from a filepath.
Inputs
A string comtaining a valide path & filename
Assumes
Put this function in a module or the declaration section of a form in which this function is needed.
Code Returns
Returns only the filename
Side Effects
It only works with VB6, this of the function 'StrReverse' which is not in previous versions of VB
Public Function ExtractFileName(ByVal strPath As String) As String
' StrReverse is only working in VB6
strPath = StrReverse(strPath)
strPath = Left(strPath, InStr(strPath, "\") - 1)
ExtractFileName = StrReverse(strPath)
End Function