|
-
October 3rd, 2001, 01:01 PM
#1
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
-
October 3rd, 2001, 01:14 PM
#2
Re: string question
Is the file name length fixed ? If so you can use Filename = right(5,URL)
Nicolas Bohemier
-
October 3rd, 2001, 01:29 PM
#3
Re: string question
the file name and url are not fixed length.
-
October 3rd, 2001, 01:44 PM
#4
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]
-
October 3rd, 2001, 01:53 PM
#5
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
-
October 3rd, 2001, 01:55 PM
#6
Re: string question
filename = Right$(url, Len(url) - InStrRev(url, "\"))
-
October 3rd, 2001, 03:07 PM
#7
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, "\"))
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
|