一个关于闹钟的VB题目

来源:百度知道 编辑:UC知道 时间:2024/05/29 12:18:33
程序启动后上方的标签动态显示系统时间。单击设置闹钟按钮后文本框可用,同时按钮变成“确定”按钮,在文本框中按“hh:mm:ss”的格式输入设定的时间,并按确定按钮,程序会在时间到达后用消息框提醒“设置的时间到了”。用两个定时器来做。谢谢

Private Sub Command1_Click()
If Text1.Text = "输入闹钟时间" Then MsgBox "请输入闹钟时间"
Command1.Caption = "闹钟设置完"
Timer1.Interval = 1000
End Sub
Private Sub Form_Load()
Text1.MaxLength = 8
Text1.Text = "输入闹钟时间"
Command1.Caption = "确定"
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) = 2 Then
Text1.Text = Text1.Text & ":"
Text1.SelStart = Len(Text1.Text)
ElseIf Len(Text1.Text) = 5 Then
Text1.Text = Text1.Text & ":"
Text1.SelStart = Len(Text1.Text)
End If
End Sub
Private Sub Text1_Click()
If Text1.Text = "输入闹钟时间" Then Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) > 6 Then KeyAscii = 0
End Sub
Private Sub Timer1_Timer()
Cls
Print "当前时间:" & Time
If Text1.Text = Time Then
MsgBox "闹钟时间到"
Comman