懂VB 的大侠进来指点一下

来源:百度知道 编辑:UC知道 时间:2024/05/15 05:10:40
怎样制作一个程序text1显示系统当前时间 text2中输入一个比系统时间晚的时间(时 分 秒)command1 开始倒计时当到达设定的时间时 显示 并且停止计时````timer1控制系统时间 timer2控制计时``
设置属性并编写代码
Private Sub Command1_Click()
Timer1.Enabled = True
Timer2.Tag = Val(Text1.Text) * 60
End Sub

Private Sub Timer1_Timer()
Text1.Text = Time$
End Sub

Private Sub Timer2_Timer()
Timer2.Tag = Timer2.Tag - 1
m = Timer2.Tag - Timer1.Tag
If m < 0 Then
Timer1.Enabled = False
MsgBox "时间到了!", 0, "到计时"
Text2.Text = Text1.Text
Exit Sub
End If
n1 = Form1(m Mod 60, "00")
n2 = Form1((m \ 60) Mod 60, "00")
n3 = Form1(m \ 3600, "00")
Text2.Text = n3 & n2 & n1
End Sub
这是我写的 各位高手 帮我看看哪些地方错拉

作业?

自己想想吧

实在不行了就翻翻书~~

确实很容易,也不用两个Timer了,只需要一个,到时候比较一下时间就可以了。
以下是我写的,你参考一下吧

Dim tBegin As Boolean

Private Sub Command1_Click()
'开始显示系统时间
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
'开始倒计时
If DateDiff("s", Text1.Text, Text2.Text) <= 0 Then
MsgBox "时间错误"
Else
tBegin = True
End If
End Sub

Private Sub Timer1_Timer()
Text1.Text = Format(Now, "long time")
If Not IsDate(Text2.Text) Then
Exit Sub
End If

If tBegin And DateDiff("s", Text1.Text, Text2.Text) <= 0 Then
Timer1.Enabled = False
Text1.Text = Text2.Text
MsgBox "时间到"
End If
End Sub

就是,看书吧,很基础!

问题不难,花几分时间的事!自己动手吧:)