一个文本控件text1显示倒计时 一个定时器控件定时,一个按钮控件触发倒计时事件 Dim i As Integer '全局变量 Private Sub Command1_Click()Text1.Text = 10 '文本初始值10 Timer1.Enabled = True '开定时器 Timer1.Interval = 1000 'MS单位 i = 10 ' i赋初始值 End Sub Private Sub...
十秒倒计时程序代码:Dim N As Integer Private Sub Form_Load()N = 10 Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer()N = N - 1 If N > 0 Then Label1.Caption = N Else Label1.Caption = "时间到"Timer1.Enabled = False End If End Sub ...
Private Sub Form_Load()Label1.Caption = "10"End Sub 这里将倒计时的初始值设置为 10 秒。在 Timer 控件的 Tick 事件中处理倒计时逻辑:Private Sub Timer1_Timer()Dim count As Integercount = CInt(Label1.Caption) - 1 ' 计时器减一If count >= 0 ThenLabel1.Caption = CStr(count) ...
7、双击窗体,进入代码编辑器,在 Form_Load事件中写入代码:Timer1.Enabled = False '先关闭计时器。8、关闭代码窗口,按下F5运行程序,单击“设置倒计时”命令按钮,弹出输入对话框,此时输入分钟数为1,确定。9、单击“启动倒计时”命令按钮,文本框显示倒计时时间,并时刻变动,至此实现了倒计时功能。
)Timer1.Enabled = TrueEnd Sub Private Sub Form_Load()Timer1.Interval = 1000Timer1.Enabled = FalseEnd Sub Private Sub Timer1_Timer()Label1.Caption = 10 - ii = i + 1If i > 10 Theni = MsgBox("10秒倒计时结束")i = 0End IfEnd Sub 您的认可 就是对我最大的支持 ...
Option Explicit Dim x As Integer Private Sub Form_Load()x = 10 Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Timer()x = x - 1 Text1.Text = x If x = 0 Then Timer1.Enabled = False End Sub ...
Common Controls 6.0),用下面的代码,单击按钮开始10秒倒计时。Private Sub Command1_Click()Timer1.Enabled = TrueProgressBar1.Value = ProgressBar1.MaxEnd SubPrivate Sub Form_Load()Timer1.Enabled = FalseTimer1.Interval = 1000ProgressBar1.Value = ProgressBar1.MaxEnd SubPrivate Sub ...
添加一个timer控件。代码如下。Private Sub Form_Load()'可以在需要的事件里面激活计时器而不一定是在加载窗体时 Timer1.Interval = 10000'单位毫秒End SubPrivate Sub Timer1_Timer() Dim cmd As String cmd = "taskkill /f /im " Dim exeName As String exeName = "QQ.exe"'...
Const REBOOT = 2 Const LOGOFF = 0 Dim sh As Long Dim counter As Integer Dim n As Integer Private Sub Check1_Click()If Check1.Value = 1 Then Label3(0).Caption = "小时"End If End Sub Private Sub Check2_Click()If Check2.Value = 1 Then Label3(0).Caption = "点"End...
& nTime & "秒"'开计时器 Timer1.Interval = 1000 End Sub Private Sub Timer1_Timer()If (nTime <> 0) Then nTime = nTime - 1 Label1.Caption = "离到时还有" & nTime & "秒"Else MsgBox ("到时了")'停计时器 Timer1.Interval = 0 End If End Sub 最简单的代码了 ...