I if have a variable that contains a path of a file(Ex: "C:\New Folder\blah.ini") how can i take that and get rid of the path, making it just "blah.ini"?
Any help is appreciated! Thank yoU!
Printable View
I if have a variable that contains a path of a file(Ex: "C:\New Folder\blah.ini") how can i take that and get rid of the path, making it just "blah.ini"?
Any help is appreciated! Thank yoU!
Code:Option Explicit
Private Sub Command1_Click()
' A text comparison starting at #1 position looking for \
Dim SearchString, SearchChar, MyPos
SearchString = "C:\New Folder\blah.ini" ' String to search in.
SearchChar = "\" ' Search for "\".
Dim i As Integer
For i = 1 To Len(SearchString)
MyPos = InStr(1, SearchString, SearchChar, 1)
'if found MyPos will be > 0
If MyPos > 0 Then
SearchString = Right(SearchString, Len(SearchString) - MyPos)
End If
Next i
MsgBox SearchString
End Sub
I just found a much much simplier way:
That returns the filename, much simplier and faster. Thanks anyway!Code:#!/usr/bin/perl
'in module
Public Function FileName(FilePath as String)
FileName = Left(FilePath, Len(FilePath) - InStrRev(FilePath, "\"))
End Function
[Edited by Xero on 09-24-2000 at 06:38 PM]
nevermind, it doesnt work =).
tested it?
Oh! To fix it replace Left with Right, silly me :).
already did that...
thanks...I'll add it to my mdb