|
-
Feb 21st, 2003, 03:35 PM
#1
Thread Starter
PowerPoster
VB Snippet - File Name from Path
VB Code:
Function GetFileName(FileName As String) As String
Dim i As Integer
On Error Resume Next
For i = Len(FileName) To 1 Step -1
If Mid(FileName, i, 1) = "\" Then
Exit For
End If
Next
GetFileName = Mid(FileName, i + 1)
End Function
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Feb 28th, 2003, 10:20 PM
#2
New Member
Here's my way 
VB Code:
Function GetFileName (FileName As String) As String
FileName = StrReverse(FileName)
Dim Pieces() As String
Pieces() = Split(FileName, "\", 2)
GetFileName = StrReverse(Pieces(0))
End Function
Last edited by ffejy; Mar 1st, 2003 at 09:40 PM.
-
Mar 1st, 2003, 09:33 PM
#3
Fanatic Member
There are some errors in you code ffejy - On the array. Very unique method once it worked.
I like to use something like this.
MsgBox Mid(FileName, InStrRev(FileName, "\") + 1)
Bird of Prey
Mr. Bald Eagle.
[img][/img]
-
Mar 1st, 2003, 09:36 PM
#4
New Member
Oops, thanks for pointing that out Hawk, fixed now. Your method is the shortest
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|