快表VBA倒计时
显示倒计时的一个VBA
效果:
VBA代码:
- Public Sub ButtunClick(sender As Object,e As SpreadsheetGear.Windows.Controls.ShapeActionEventArgs)
- If String.Equals(e.Shape.Name,"Button 1") = True Then
- e.Shape.Visible = False
- Range("C2").Value = 0
- ''计时器(避免造成大频率循环造成资源占用)
- Dim XHTimer As DispatcherTimer = New DispatcherTimer
- XHTimer.Interval = New TimeSpan(0, 0, 0, 1, 0)'60秒
- AddHandler XHTimer.Tick, Sub(s1, e1)
- ActiveWorkBook.WorkbookSet.getlock()
- If Range("C2").Value >= 5 Then
- C1MessageBox.Show("时间到!", "快表提示", OK, Information)
- XHTimer.Stop()'停止计时器
- e.Shape.Visible = True
- Else
- Range("C2").Value = Range("C2").Value + 1
- End If
- ActiveWorkBook.WorkbookSet.ReleaseLock()
- End Sub
-
- XHTimer.Start()'开始计时器
- End If
- End Sub'按钮/标签点击事件
复制代码
|
|
hessen