VB程序设计阶段试题(练习题) 题目:10秒定时器

2024-12-04 17:28:03
推荐回答(1个)
回答1:

Option Explicit

Private Sub Command1_Click() '复原
Text1.Text = ""
Shape1.BackColor = vbRed
Timer1.Enabled = False

End Sub

Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer) '在文本框中输入时间(单位秒,不能超过65秒),回车确认
If KeyAscii = 13 Then
Timer1.Interval = Val(Text1.Text) * 1000
Timer1.Enabled = True
End If
End Sub

Private Sub Timer1_Timer()
Shape1.BackColor = vbBlue '变为红色
End Sub