Results 1 to 3 of 3

Thread: [RESOLVED] How to remove everything after last slash(/) including slash itself ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Resolved [RESOLVED] How to remove everything after last slash(/) including slash itself ?

    hi all . i am extracting a list of urls from webbrowser controle but i want to remove everthing after the last slash including the slash . could any one telll me how this can be done? thanks

    Example the urls are like this

    aHref.href=123456/new-song-album1 and i want to get only this part only :123456 then add it to listbox. I want to do this process in loop for all values of aHref.href.

    Code:
    Private Sub Command2_Click()
    Dim doc As HTMLDocument
    Dim aHref As HTMLAnchorElement
    
    Set doc = WebBrowser1.Document
    
    For Each aHref In WebBrowser1.Document.All.tags("A")
    
    List1.AddItem aHref.href
    
    Next aHref
    
    
    End Sub
    Last edited by tony007; Oct 24th, 2012 at 06:44 PM.

  2. #2
    PowerPoster
    Join Date
    Aug 2011
    Location
    B.C., Canada
    Posts
    2,887

    Re: How to remove everything after last slash(/) including slash itself ?

    single split should do the trick

    Code:
    Private Sub Command2_Click()
    Dim doc As HTMLDocument
    Dim aHref As HTMLAnchorElement
    dim hrefSPLIT() as string
    
    Set doc = WebBrowser1.Document
    
      For Each aHref In WebBrowser1.Document.All.tags("A")
        hrefSPLIT = split(aHref.href,"/")
        List1.AddItem  hrefSPLIT(0)
      Next aHref
    End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: [RESOLVED] How to remove everything after last slash(/) including slash itself ?

    Max many many thanks it solved the problem!

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