by C.J. (13 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Sat 2nd January 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Retrieve a file name without the extension
'Parses the filename out of a directory string
'Returns the FileName w/o the extension
Dim i As Integer
Dim lpFileName As String
On Error Resume Next
For i = Len(fname) To 1 Step -1
If Mid(fname, i, 1) = "\" Then
Exit For
End If
Next
lpFileName = Mid$(fname, i + 1)
i = InStr(Mid(fname, i + 1), ".")
If i > 1 Then
GetFileName = Mid(lpFileName, 1, i - 1)
End If
End Function