VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Retrieve a file name without the extension

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

Rate 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

Download this snippet    Add to My Saved Code

Retrieve a file name without the extension Comments

No comments have been posted about Retrieve a file name without the extension. Why not be the first to post a comment about Retrieve a file name without the extension.

Post your comment

Subject:
Message:
0/1000 characters