[Vb.net] Go through all sites in listbox?

Posts 1–7 of 7 · Page 1 of 1
[Vb.net] Go through all sites in listbox?
Ok here is my code so far, but im stuck:

Code:
 For i As Integer = 0 To ListBox2.Items.Count - 1
            WebBrowser1.Navigate(ListBox2.Items.Item(i).ToString())
        Next
This code only visits the second site on the listbox.
Why? Can anyone see the problem.
Wouldn't it be

To Listbox2.Items.Count + 1?
nope cause
ListBox2.Items.Item(i).ToString() starts from i=0
What exactly you want to do ?? I mean how much you want to wait before loading another website in the listbox !!! ?
Quote Originally Posted by ipwnuuaal5 View Post
Basically i have several websites in listbox2.
For example it listbox2.items contains:
Google
MPGH - MultiPlayer Game Hacking - Hack Hacks Downloads, Combat Arms Hacks, CrossFire Hacks, WarRock Hacks, Soldier Front Hacks, Sudden Attack Hacks, Operation 7 Hacks, AVA Hacks, Battlefield Hacks, Bad Company 2 Hacks, Call of Duty Hacks, Modern Warf
www.gmail.com
Sign In

So basically all i want to do is to go through all the websites with 5 seconds to view each page.
Create a Timer in the form. Set its interval to 5000 (for 5 seconds). Do not enable it. Then add the following code to the form. Modify it as needed:

[php]Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox2.SelectedIndex = 0
End Sub
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) Handles WebBrowser1.DocumentCompleted
Application.DoEvents()
Timer1.Enabled = True
End Sub
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
WebBrowser1.Navigate(ListBox2.SelectedItem)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Not ListBox2.SelectedIndex = ListBox2.Items.Count - 1 Then
ListBox2.SelectedIndex += 1
Timer1.Enabled = False
End If
End Sub[/php]

This will navigate through a site, and when the site has completely loaded, waits for 5 seconds and then moves to the next website (Listbox Item).
Hope this helps !!
[php]
Listbox2.selectedindex = 0
For i As Integer = 0 To ListBox2.Items.Count - 1
Dim NewItem as integer = 0
listbox2.selectedindex = NewItem
WebBrowser1.Navigate(listbox2.selecteditem())
newItem = Newitem + 1
Next
[/php]
Should work, I guess.
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Talk with us