Results 1 to 5 of 5

Thread: [resolved] parsing help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    [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.

  2. #2
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Re: parsing help

    thanks, works perfectly

  4. #4
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: parsing help

    Quote Originally Posted by Whatupdoc
    thanks, works perfectly
    You're welcome.


  5. #5
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    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
  •  



Click Here to Expand Forum to Full Width