View Full Version : Get the file name from a string !
OMID SOFT
04-20-04, 07:26 PM
I have a string include the :
Drive \ Path [ \Path\ ] \ FileName.FileExt
And I want to exclude the Drive and Path from it.
I need just the FilneName.FileExt !
Is here anyone that can help me ?
Thank you.
Omid Soroori of OMID SOFT.
hyjacked
04-20-04, 08:48 PM
ummm, not necessarily the best way to do it, but reverse the string, look for the first \, truncate everything after that, then reverse the string again. this will give you what you want.
ummm, not necessarily the best way to do it, but reverse the string, look for the first \, truncate everything after that, then reverse the string again. this will give you what you want.
With a textbox and a button on a form, try the following code:
Private Sub Command1_Click()
Dim s As String
Dim a() As String
s = "c:\path1\path2\path3\filename.fil"
a = Split(s, "\")
Text1.Text = a(UBound(a))
End Sub
kevin
hyjacked
04-29-04, 12:17 AM
nicely done kebo. :)
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.