This is a function that extracts the Filename (with or without the extension) from the path.
This is a function that extracts the Filename (with or without the extension) from the path.
Rate This is a function that extracts the Filename (with or without the extension) from the path.
(1(1 Vote))
'This .bas file was created by Barabas Andrei
'You can use it without deleting this header
'
'To use this function, you have to provide the
'path of the file
'if you want to extract only the name (without the
'extension, you have to call the function like this
'
'Ex: FileName("C:\Windows\setup.bmp",true) => "setup"
'
'else use the function like this
'
'Ex: FileName("C:\Windows\setup.bmp",false) => "setup.bmp"
'===========================================
Public Function FileName(ByVal path As String, ByVal t As Boolean) As String
Dim y As Integer
y = 1
While Left$(Right$(path, y), 1) <> "\"
y = y + 1
Wend
path = Right$(path, y - 1)
If t Then
y = 1
While (Left$(Right$(path, y), 1) <> ".") And (y <= 4)
y = y + 1
Wend
If (Left$(Right$(path, y), 1) = ".") Then
path = Left$(path, Len(path) - y)
End If
End If
FileName = path
End Function
This is a function that extracts the Filename (with or without the extension) from the path. Comments
No comments yet — be the first to post one!
Post a Comment