这是我的代码:
Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
Video1.Start()
Video1.Interval = 4000
ToolStripStatusLabel2.Text = "Browsing"
End Sub
Private Sub Video1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Video1.Tick
ToolStripStatusLabel4.Text += 1
ListBox1.SelectedIndex = rnd.Next(0, ListBox1.Items.Count - 1)
WebBrowser1.Navigate(ListBox1.SelectedItem)
End Sub
问题是可以说计时器间隔设置为4秒(4000)。我希望我的应用程序按以下顺序导航到我的列表框中的每个项目:website1,website 2,website3等。而是这样做:网站5,网站2,网站8,网站1。导航到随机网站。
它是随机的,原因似乎是因为您正在调用随机数生成器并从列表框中选择该项目:
rnd.Next(0, ListBox1.Items.Count - 1)
相反,您应该分配一个变量来存储您当前在哪个索引上。每次计时器计时时增加此值。
Private currentIndex As Integer = 0
Private Sub Video1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Video1.Tick
ToolStripStatusLabel4.Text += 1
currentIndex += 1
ListBox1.SelectedIndex = currentIndex
WebBrowser1.Navigate(ListBox1.SelectedItem)
End Sub
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句