ExtractFileName

By | 2002-06-01

It extracts a filename from a filepath.

Original Author: D. de Haas

Inputs

A string comtaining a valide path & filename

Assumptions

Put this function in a module or the declaration section of a form in which this function is needed.

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

Code

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

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.