• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

1+ on next page

hello,
I have this button but I would like to make something so that it goes to the next page
page1 has this code -> javascript:GotoPage(2);
page2 has this code -> javascript:GotoPage(3);
etc... until 250

this code is working fine but it only goes to page 2, so I would like to make something
that goes to the next page every 5 secs. how can I do this?

   Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click

        Dim thisDoc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
        For Each objItem As Object In thisDoc.all.tags("a")
            If objItem.HRef = "javascript:GotoPage(2);" Then
                objItem.Click()
                Exit For
            End If
        Next

    End Sub
0
aplelois
Asked:
aplelois
  • 6
  • 6
1 Solution
 
bruintjeCommented:
Hello aplelois,

you can try something like

1. put the timer on the form and set it to 5000 milliseconds
2. you can opt for enabling the timer on a button click as you did in an earlier question
3. in the timer tick you an put the next click

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim thisDoc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
        For Each objItem As Object In thisDoc.all.tags("a")
          If InStr(objItem.HRef, "javascript:GotoPage(") > 0 Then ' check here if the gotopage is part of the href of this object
                objItem.Click()
                Exit For
          End If
        Next
End Sub

hope this helps a bit
bruintje
0
 
apleloisAuthor Commented:
is going to page 2 then page 1 then page 2 etc...
0
 
apleloisAuthor Commented:
well the page also has this in it too!

<a href="javascript:GotoPage(1);">1</a>
<a href="javascript:GotoPage(2);">2</a>
<a href="javascript:GotoPage(3);">3</a>
<a href="javascript:GotoPage(4);">4</a>
<a href="javascript:GotoPage(5);">5</a>
<a href="javascript:GotoPage(250);">250</a>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bruintjeCommented:
ok didn't see that

you could declare a integer in your form as a sort of module variable

    Dim myInt As Integer

then when the timertick comes by you use it to click the correct button and add 1 tot the counter

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim thisDoc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
        For Each objItem As Object In thisDoc.all.tags("a")
            If objItem.HRef = "javascript:GotoPage(" & myInt & ");" Then
                objItem.Click()
                myInt = myInt + 1
                Exit For
            End If
        Next
    End Sub
0
 
apleloisAuthor Commented:
is not working
0
 
bruintjeCommented:
where is the gotopage starting i see i forgot to set an initial value so it will probably start looking for 0 and its not there

if its 2 then

Dim myInt As Integer = 2

then when the timertick comes by you use it to click the correct button and add 1 tot the counter

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim thisDoc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
        For Each objItem As Object In thisDoc.all.tags("a")
            If objItem.HRef = "javascript:GotoPage(" & myInt & ");" Then
                objItem.Click()
                myInt = myInt + 1
                Exit For
            End If
        Next
    End Sub
0
 
apleloisAuthor Commented:
amazing! thank you so much!
0
 
bruintjeCommented:
glad to help, thanks for the grade :)
0
 
apleloisAuthor Commented:
bruintje, how can I make it stop when is at the 150 page?
0
 
bruintjeCommented:
   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim thisDoc As mshtml.IHTMLDocument2 = WebBrowser1.Document.DomDocument
     if myInt = 150 then
        Timer1.Enabled = False  
        Exit sub
     end if
     For Each objItem As Object In thisDoc.all.tags("a")
            If objItem.HRef = "javascript:GotoPage(" & myInt & ");" Then
                objItem.Click()
                myInt = myInt + 1
                Exit For
            End If
        Next
    End Sub
0
 
apleloisAuthor Commented:
oh man how I love VB.NET is so cool, thanks again! whooo
0
 
bruintjeCommented:
glad you are happy, looking at all those questions you are really building some application while i only help with parts :-)

good luck with the project
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now