vba msgbox问题
我的excel里有两个倒计时,我想用vba代码倒计时剩下1分钟的时候系统弹一个msgbox出来提示用户,并且这个窗口出现在最顶层,方便用户看到。Dimbl,beAsBoo...
我的excel里有两个倒计时,我想用vba代码倒计时剩下1分钟的时候系统弹一个msgbox出来提示用户,并且这个窗口出现在最顶层,方便用户看到。
Dim bl, be As Boolean
Public Sub red()
With Application
.OnTime Now + TimeValue("00:00:01"), "uf"
Call aa
End With
End Sub
Sub uf()
UserForm1.Show
aa
End Sub
Sub aa()
If bl Then End
UserForm1.TextBox1 = Format(Time, "hh:mm:ss")
If (Now - t1) * 3600 * 24 > 300 Then
UserForm1.TextBox2 = "00:00:00"
Else
UserForm1.TextBox2 = Format(TimeValue("00:05:00") - Time + t, "hh:mm:ss")
End If
If (Now - t1) * 60 * 24 > 30 Then
UserForm1.TextBox3 = "00:00:00"
Else
UserForm1.TextBox3 = Format(TimeValue("00:30:00") - Time + t, "hh:mm:ss")
End If 展开
Dim bl, be As Boolean
Public Sub red()
With Application
.OnTime Now + TimeValue("00:00:01"), "uf"
Call aa
End With
End Sub
Sub uf()
UserForm1.Show
aa
End Sub
Sub aa()
If bl Then End
UserForm1.TextBox1 = Format(Time, "hh:mm:ss")
If (Now - t1) * 3600 * 24 > 300 Then
UserForm1.TextBox2 = "00:00:00"
Else
UserForm1.TextBox2 = Format(TimeValue("00:05:00") - Time + t, "hh:mm:ss")
End If
If (Now - t1) * 60 * 24 > 30 Then
UserForm1.TextBox3 = "00:00:00"
Else
UserForm1.TextBox3 = Format(TimeValue("00:30:00") - Time + t, "hh:mm:ss")
End If 展开
1个回答
展开全部
在模块中定义:public flag1,public flag2,在程序的启动按钮中先将flag2,flag1附为true,
string1 = CStr(UserForm1.TextBox2)
string2 = CStr(UserForm1.TextBox3)
If Int(Left(string1, 2)) = 0 And Int(Mid(string1, 4, 2)) = 0 Then
'最后一分钟时将字体变红
UserForm1.TextBox2.ForeColor = 255
If flag1 Then
'最后一分钟时用msgbox跳出提示,只跳出一次.
MsgBox "时间1还剩最后一分钟!"
flag1 = False
End If
End If
If Int(Left(string2, 2)) = 0 And Int(Mid(string2, 4, 2)) = 0 Then
'最后一分钟时将字体变红
UserForm1.TextBox3.ForeColor = 255
If flag2 Then
'最后一分钟时用msgbox跳出提示,只跳出一次.
MsgBox "时间2还剩最后一分钟!"
flag2 = False
End If
End If
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询