標題:
此文章來自奇摩知識+如有不便請留言告知
VISUAL BASIC 倒數計時 做法
發問:
我想寫個program 我有一個command1,一個text1,一個timer1 我想一禁個command1,個text1就彈個分鐘出黎倒數。 例如五分鐘。 我寫左好多次,係網上睇左好多野都做唔到。 如果可以,可唔可以咁樣顯示: xx分xx秒 唔該晒~~
最佳解答:
Option Explicit Private Sub Form_Load() Form1.Caption = "倒數計時" Command1.Caption = "開始倒數" Text1 = "" Label1.BorderStyle = vbFixedSingle Label1 = "" End Sub Private Sub Command1_Click() Dim BeforeTime As Single Static InDo As Boolean InDo = Not InDo If InDo Then If Not IsDate(Text1) Then MsgBox "無效的時間格式" Else BeforeTime = Timer Command1.Caption = "取消" Text1.Enabled = False Label1 = Format(Text1, "hh:mm:ss") Do While Label1 "00:00:00" If Not InDo Then Exit Do If Timer >= BeforeTime + 1 Then BeforeTime = Timer Label1 = Format(DateAdd("s", -1, Label1), "hh:mm:ss") End If DoEvents Loop Command1.Caption = "開始倒數" Text1.Enabled = True Label1 = "00:00:00" End If InDo = False End If End Sub 在網上找的,我5知得5得,你試下先,5得再問. 看參考網址!!!!
其他解答: