VB 设计倒计时,text1表示分钟 text2表示秒数 但是代码出现问题,求帮我看看
PrivateSubCommand1_Click()Timer1.Enabled=TrueEndSubPrivateSubCommand2_Click()Timer1.E...
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim a As Integer, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b <> 0 Then
b = b - 1
ElseIf b = 0 And a <> 0 Then
a = a - 1 And b = 59
ElseIf a = 0 And b = 0 Then
Beep
MsgBox "计时时间到"
End If
Text1.Text = Format(a, "00")
Text1.Text = Format(b, "00")
End Sub 展开
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim a As Integer, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b <> 0 Then
b = b - 1
ElseIf b = 0 And a <> 0 Then
a = a - 1 And b = 59
ElseIf a = 0 And b = 0 Then
Beep
MsgBox "计时时间到"
End If
Text1.Text = Format(a, "00")
Text1.Text = Format(b, "00")
End Sub 展开
2个回答
展开全部
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim a As Integer, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b > 0 Then
b = b - 1
ElseIf a > 0 Then
a = a - 1
b = 59
Else
Beep
Timer1.Enabled = False
MsgBox "计时时间到"
End If
Text1.Text = Format(a, "00")
Text2.Text = Format(b, "00")
End Sub
TableDI
2024-07-18 广告
2024-07-18 广告
仅需3步!不写公式自动完成Excel vlookup表格匹配!Excel在线免,vlookup工具,点击13步自动完成表格匹配,无需手写公式,免费使用!...
点击进入详情页
本回答由TableDI提供
展开全部
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load() ‘初始化
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim a As Integer, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b <> 0 Then
b = b - 1
Else ‘以下部分作了修改
If a <> 0 Then
a = a - 1: b = 59
Else
Beep
MsgBox "计时时间到"
Timer1.Enabled = False
End If
End If
Text1.Text = Format(a, "00")
Text2.Text = Format(b, "00") ’此句也作了修改
End Sub
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load() ‘初始化
Timer1.Interval = 1000
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim a As Integer, b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If b <> 0 Then
b = b - 1
Else ‘以下部分作了修改
If a <> 0 Then
a = a - 1: b = 59
Else
Beep
MsgBox "计时时间到"
Timer1.Enabled = False
End If
End If
Text1.Text = Format(a, "00")
Text2.Text = Format(b, "00") ’此句也作了修改
End Sub
更多追问追答
追问
为什么我这样写就不对呢。。。分钟和秒钟在运行的时候 分钟跟着秒钟变了。。。
追答
你没仔细看。最后一处修改的地方。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询