Results 1 to 8 of 8

Thread: [RESOLVED] Navigate to Hyperlink -- VB6

  1. #1

    Thread Starter
    Lively Member wiz....'s Avatar
    Join Date
    Nov 2008
    Location
    Asia, Earth, Solar System, Milky Way Galaxy, Near Andromeda Galaxy, Universe
    Posts
    78

    Resolved [RESOLVED] Navigate to Hyperlink -- VB6

    Hey Guyz....

    I was writing a code on VB6 to download the picture albums of my friends on Facebook. I have written the code to save the images currently being displayed on the web page(Webbrowser1).

    But I am facing a Problem....I need to navigate to the next picture....How ??

    I was thinking that if the code navigates to the HREF(link) behind the "Next" hyperlink on the page....my code would run.

    So I need your help on HOW to Click on the "Next" or the "Previous" hyperlink on the WebBrowser component.


    <ul class="pagerpro"><li class="pagerpro_li"><a href="/photo.php?pid=406412&amp;id=1342142580" id="photonav_prev" class="pagerpro_a">Previous</a></li><li class="pagerpro_li"><a href="/photo.php?pid=8388&amp;id=1342142580" id="photonav_next" class="pagerpro_a">Next</a></li></ul></div></div>



    Thank You in advance.
    Last edited by wiz....; Jan 30th, 2010 at 01:06 AM. Reason: forgot to add Facebook and some errors !

  2. #2
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: Navigate to Hyperlink -- VB6

    Something like this should work...
    Code:
    Private Function FindNextLinkUrl() As String
    
    Dim CollectionOfLinks As Object, Link As Object
    
    Set CollectionOfLinks = WB.Document.getelementsbytagname("A")
    
    For Each Link In CollectionOfLinks
      If UCase(Link.innertext) = UCase("next") Then
        FindNextLinkUrl = Link.href
        Exit For
      End If
    Next Link
    
    End Function
    However, it is untested as I could not think of a site that had a next link on it. I guess I need more caffine...



    Good Luck
    Option Explicit should not be an Option!

  3. #3

    Thread Starter
    Lively Member wiz....'s Avatar
    Join Date
    Nov 2008
    Location
    Asia, Earth, Solar System, Milky Way Galaxy, Near Andromeda Galaxy, Universe
    Posts
    78

    Re: Navigate to Hyperlink -- VB6

    Facebook has a next link !!!! but yeah...ill try it.....!!!
    PAIN n SUFFERING-Pain is Inevitable,,suffering is optional...........
    WORK EXPECTATION--U can do anything in this world if u don't look for credit.........

  4. #4

    Thread Starter
    Lively Member wiz....'s Avatar
    Join Date
    Nov 2008
    Location
    Asia, Earth, Solar System, Milky Way Galaxy, Near Andromeda Galaxy, Universe
    Posts
    78

    Re: Navigate to Hyperlink -- VB6

    Doesnt work !!!!! No errors in the code though....!!!! Nothing Happens !!!
    PAIN n SUFFERING-Pain is Inevitable,,suffering is optional...........
    WORK EXPECTATION--U can do anything in this world if u don't look for credit.........

  5. #5
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: Navigate to Hyperlink -- VB6

    It is not for navigation, it is for finding the link so you can navigate to it via WB.Navigate FindNextLinkUrl and I don't book nor do I tweet!!!



    Good Luck
    Option Explicit should not be an Option!

  6. #6

    Thread Starter
    Lively Member wiz....'s Avatar
    Join Date
    Nov 2008
    Location
    Asia, Earth, Solar System, Milky Way Galaxy, Near Andromeda Galaxy, Universe
    Posts
    78

    Re: Navigate to Hyperlink -- VB6

    i aktually tryed 2 navigate it....i still din get the required link.
    PAIN n SUFFERING-Pain is Inevitable,,suffering is optional...........
    WORK EXPECTATION--U can do anything in this world if u don't look for credit.........

  7. #7
    Frenzied Member
    Join Date
    Mar 2009
    Posts
    1,182

    Re: Navigate to Hyperlink -- VB6

    Well, have you tried debug.print to see if it returns any result? Have you used F8 to step through the code to see how and if it works? Have you tested the values to see if you might also need to add a trim() function because "next" and " next " do not equal each other? Because this works...
    Code:
    Option Explicit
    
    Private Sub Form_Load()
    Command1.Enabled = False
    Me.Visible = True
    NavigateWebBrowser "http://www.vbforums.com/forumdisplay.php?f=1"
    Command1.Enabled = True
    End Sub
    
    Private Sub NavigateWebBrowser(LinkToNavTo As String)
    
    WB.Navigate LinkToNavTo
    Do While WB.ReadyState <> READYSTATE_COMPLETE
      DoEvents
    Loop
    
    End Sub
    
    Private Sub Command1_Click()
    'Navigate to Hyperlink -- VB6
    Dim CollectionOfLinks As Object, Link As Object
    Set CollectionOfLinks = WB.Document.body.getelementsbytagname("A")
    For Each Link In CollectionOfLinks
      If Trim(UCase(Link.innertext)) = Trim(UCase("Navigate to Hyperlink -- VB6")) Then
        NavigateWebBrowser CStr(Trim(Link.href))
        Exit For
      End If
    Next
    End Sub


    Good Luck
    Option Explicit should not be an Option!

  8. #8

    Thread Starter
    Lively Member wiz....'s Avatar
    Join Date
    Nov 2008
    Location
    Asia, Earth, Solar System, Milky Way Galaxy, Near Andromeda Galaxy, Universe
    Posts
    78

    Re: Navigate to Hyperlink -- VB6

    Amazing.....this code works...thnx !!!!
    PAIN n SUFFERING-Pain is Inevitable,,suffering is optional...........
    WORK EXPECTATION--U can do anything in this world if u don't look for credit.........

Tags for this Thread

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