VB问题呀

来源:百度知道 编辑:UC知道 时间:2024/06/05 22:48:01
我想做一个程序:一个文本框,里面依次出现1 2 3 4 5.....
每次出现一个
命令按钮一开始为开始,当开始后,变成停止
怎么定义一个范围 数的范围1至50

Dim i As Integer

Private Sub Command1_Click()
Timer1.Interval = 1000
End Sub

Private Sub Form_Load()
i = 1
Label1.Caption = ""
Label1.BackColor = &HFFFFFF
Command1.Caption = "Click Me"
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Label1.Caption + " " + CStr(i)
If i = 50 Then
Timer1.Interval = 0
Exit Sub
End If
i = i + 1
If i Mod 2 = 0 Then
Command1.Caption = "开始"
Else
Command1.Caption = "停止"
End If
End Sub

完整代码如上,不知道是否符合楼主的意思?
在窗体中添加三个控件:Label,Timer和CommandBox
单击按钮实现功能^_^
已经按照楼主的意思新增设定范围1-50啦!

Dim i As Integer

Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Timer1.Enabled = True
Command1.Caption = "停止"
Else
Timer1.Enabled