|
-
Apr 7th, 2007, 08:29 PM
#1
Thread Starter
Hyperactive Member
[resolved] parsing help
How would i do this?
User Input: http://www.mysite.com/image1.gif
output: image1.gif
User Input: http://www.notmysite.com/folder/image2.jpg
output: image2.jpg
User Input: http://www.mysite.com/folder/folder2/image10.gif
output: image10.gif
i can't figure out how to get the images name from the URL, can someone help?
Last edited by Whatupdoc; Apr 7th, 2007 at 08:43 PM.
-
Apr 7th, 2007, 08:32 PM
#2
Re: parsing help
Code:
Option Explicit
Private Function GetURLFile(URL As String) As String
Dim intPos As Integer
intPos = InStrRev(URL, "/")
If intPos > 0 Then
GetURLFile = Mid$(URL, intPos + 1)
End If
End Function
Private Sub Form_Load()
MsgBox GetURLFile("http://www.mysite.com/image1.gif")
MsgBox GetURLFile("http://www.notmysite.com/folder/image2.jpg")
MsgBox GetURLFile("http://www.mysite.com/folder/folder2/image10.gif")
End Sub
-
Apr 7th, 2007, 08:43 PM
#3
Thread Starter
Hyperactive Member
-
Apr 7th, 2007, 08:45 PM
#4
Re: parsing help
 Originally Posted by Whatupdoc
thanks, works perfectly
You're welcome.
-
Apr 7th, 2007, 08:49 PM
#5
Re: [resolved] parsing help
or you can do it in one line of code.
Code:
Private Function GetFile(URLFile As String) As String
GetFile = Mid$(URLFile, InStrRev(URLFile, "/", -1) + 1, Len(URLFile))
End Function
Private Sub Form_Load()
MsgBox GetFile("http://www.mysite.com/image1.gif")
MsgBox GetFile("http://www.notmysite.com/folder/image2.jpg")
MsgBox GetFile("http://www.mysite.com/folder/folder2/image10.gif")
End Sub
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
|