將文字框的Text屬性清空,將字型Font屬性調整為小四,便於觀察,將背景色屬性Backcolor調為淺黃色。
a = InputBox("請輸入倒計時時間(以分為單位):", "倒計時輸入框"
Timer1.Interval = 1000 "設定計時器為一秒發生一次
Timer1.Enabled = True "啟用計時器
If a < 60 Then
m = a
Else
h = s \ 60
m = a Mod 60
End If
m = m - 1
s = 60
雙擊“計時器”控制元件,進入程式碼編輯視窗,輸入如下程式碼:
s = s - 1
If s = 0 And m <> 0 Then
If m = 0 And h <> 0 Then
h = h - 1
m = 59
在程式碼編輯視窗的通用段進行變數定義:
Dim h As Integer, m As Integer, s As Integer "分別儲存時分秒
Dim a As Integer
雙擊窗體,進入程式碼編輯器,在 Form_Load事件中寫入程式碼:
Timer1.Enabled = False "先關閉計時器
將文字框的Text屬性清空,將字型Font屬性調整為小四,便於觀察,將背景色屬性Backcolor調為淺黃色。
a = InputBox("請輸入倒計時時間(以分為單位):", "倒計時輸入框"
Timer1.Interval = 1000 "設定計時器為一秒發生一次
Timer1.Enabled = True "啟用計時器
If a < 60 Then
m = a
Else
h = s \ 60
m = a Mod 60
End If
m = m - 1
s = 60
雙擊“計時器”控制元件,進入程式碼編輯視窗,輸入如下程式碼:
s = s - 1
If s = 0 And m <> 0 Then
s = 60
m = m - 1
End If
If m = 0 And h <> 0 Then
h = h - 1
m = 59
s = 60
在程式碼編輯視窗的通用段進行變數定義:
Dim h As Integer, m As Integer, s As Integer "分別儲存時分秒
Dim a As Integer
雙擊窗體,進入程式碼編輯器,在 Form_Load事件中寫入程式碼:
Timer1.Enabled = False "先關閉計時器