-
string question
I have a string (a url which is not fixed length) as follows:
http:\\www.yahoo.com\faq\my.jsp
I want to get 'my.jsp' from the whole string, that is, I want to the file name 'my.jsp'. It can be like
http:\\www.goto.com\ad\page1\you.html.
In this case, I want to get 'you.html'
Please tell me how to do it.
thanks
-
Re: string question
Is the file name length fixed ? If so you can use Filename = right(5,URL)
-
Re: string question
the file name and url are not fixed length.
-
Re: string question
Using InStr function find the last "\" and everything to the right will be your file. It is the same how to extract file name from the path.
Iouri Boutchkine
[email protected]
-
Re: string question
You can use an API if you strip the http: off the front... ie.
option Explicit
private Declare Function GetFileTitle Lib "comdlg32.dll" Alias "GetFileTitleA" (byval lpszFile as string, byval lpszTitle as string, byval cbBuf as Integer) as Integer
private Sub Form_Load()
'KPD-Team 2000
'URL: http://www.allapi.net/
'E-Mail: [email protected]
Dim Buffer as string
Buffer = string(255, 0)
GetFileTitle "\\www.yahoo.com\faq\my.jsp", Buffer, len(Buffer)
Buffer = Left$(Buffer, InStr(1, Buffer, Chr$(0)) - 1)
MsgBox Buffer
End Sub
-
Re: string question
filename = Right$(url, Len(url) - InStrRev(url, "\"))
-
Re: string question
Use the InStrRev function:
Dim url As String
url = "http:\\www.yahoo.com\faq\my.jsp"
url = Right(url, Len(mystr) - InStrRev(url, "\"))