![]() |
|
提问:VB时间问题
Dim Hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim Time As Date
Private Sub Mydisplay()
Hours = Val(Text1.Text)
Minutes = Val(Text2.Text)
Seconds = Val(Text3.Text)
Time = TimeSerial(Hours, Minutes, Seconds)
Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
Command3.Enabled = False
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
MsgBox "倒计时暂停", 0, "提示"
Command3.Enabled = True
End Sub
Private Sub Command3_Click()
MsgBox "倒计时终止", 0, "提示"
Hours = 0
Minutes = 0
Seconds = 0
Time = 0
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text1.SetFocus
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Form1.Top = (Screen.Height - Form1.Height) / 2
Form1.Left = (Screen.Width - Form1.Width) / 2
Timer1.Interval = 1000
Hours = 0
Minutes = 0
Seconds = 0
Time = 0
End Sub
Private Sub Text1_Change()
Mydisplay
End Sub
Private Sub Text2_Change()
Mydisplay
End Sub