Quantcast
Viewing all articles
Browse latest Browse all 12583

Reload Browser using List Items

Dear friends,

I have a developed a browser app with VB 2010.

In the ListBox, I have a list of urls that each will auto load after 15sec using the Timer_Tick method.

If the urls in the ListBox are exhausted, the IndexVariable should restart from the 1st Index of the ListBox Items - i.e, there should be a loop until StopButton_clicked event is called.

Pls check the following Code:

'this is a Module Class Variable declared as Public Public indexValue As Integer = 0 'The Timer.Interval value = 15000ms = 15sec

'the is the Start Timer Button Event Private Sub startTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startTime.Click LoadTime.Start() lblCount.Text = "" ToolStripStatusLabel1.Text = "Timer Started..." End Sub

'this is the Timer_Tick event Private Sub LoadTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadTime.Tick WebPageBrowser.Navigate(conv_urls.Items(indexValue)) 'this is where the error occurs... as

' InvalidArgument=Value of '3' is not valid for 'index'. Parameter name: index'

'Note that there are only 3 items in the ListBox...

' ' Increment the shared variable ' indexValue = indexValue + 1 'But I want the system to loop from beginning. 'here, conv_urls is a ListBox control If indexValue > conv_urls.Items.Count Then indexValue = 0 LoadTime.Interval = 0 'LoadTime.Stop() End If 'Loop End Sub

'this is the Stop Timer Button Event

 Private Sub StopBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopBut.Click
        If LoadTime.Interval = 15000 Then
            Exit Sub
        Else
            WebPageBrowser.Stop() 'this is the WebBrowser Control
            LoadTime.Stop()
            indexValue = 0
            LoadTime.Interval = 0
            ToolStripStatusLabel1.Text = "Timer Stopped!"
        End If

    End Sub

Please help me.
Thank you!



Eyo Honesty







Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>