当前位置: 代码迷 >> VB Dotnet >> VB.Net 回车后标签随机循环显示数字,但再度回车无法暂停循环
  详细解决方案

VB.Net 回车后标签随机循环显示数字,但再度回车无法暂停循环

热度:397   发布时间:2016-04-25 01:59:14.0
VB.Net 回车后标签随机循环显示数字,但再次回车无法暂停循环
本帖最后由 hanstom 于 2015-10-22 14:27:35 编辑
请教:
窗体在接收到回车后标签随机循环滚动显示数字,希望再次回车时暂停循环,显示一个数字,当再次回车是继续随机循环滚动显示数字。

代码如下:
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
  相关解决方案