现在当我在我的一个项目中有我的代码时,这是唯一的代码(请注意,我有一个包含大约29项物品的列表框!),该功能正常工作并循环遍历每个项目并给出它作为一个消息框。
当我将这段代码输入我的大项目时,我精心复制粘贴代码,计时器中的循环每次都会停止3次。即使我进入计时器1。
If Count < "29" Then
每次三次都会停止。我做错了什么,消息来源几乎相同?!
代码:
Public Class Form1
Dim NumberOfItems As Integer
Dim Count As String
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If Timer1.Enabled = False Then
Timer1.Enabled = True
Button2.Text = "Stop Timer"
NumberOfItems = ListBox1.Items.Count
Count = "0"
Else
Timer1.Enabled = False
Button2.Text = "Start Timer"
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If Count < NumberOfItems Then
Dim CurrentIt3m As String = ListBox1.Items(Count)
MsgBox(CurrentIt3m)
Count = Count + 1
Else
Button2.Text = "Start Timer"
End If
End Sub
End Class