请教:
窗体在接收到回车后标签随机循环滚动显示数字,希望再次回车时暂停循环,显示一个数字,当再次回车是继续随机循环滚动显示数字。
代码如下:
Public Class Form1
Dim objRandom As Random = New Random
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
Do
Timer1.Start()
Loop Until e.KeyCode = Keys.Enter
End Sub
'Timer1的interval=100
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
'Get the amount of pics file in the image folder
Dim intPic As Integer = objRandom.Next(1, 60)
lblText.Text = intPic
End Sub
End Class
------解决思路----------------------
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
if e.KeyCode = Keys.Enter then
Timer1.Enable= not Timer1.Enable
endif
End Sub