1樓:匿名使用者
option explicit
dim h as integer, m as integer, s as integer
private sub command1_click()if not isnumeric(text1.text) thenmsgbox "請正確小時數!"
exit sub
end if
if not isnumeric(text2.text) thenmsgbox "請正確分鐘數!"
exit sub
end if
if not isnumeric(text3.text) thenmsgbox "請正確秒數!"
exit sub
end if
h = text1.text
m = text2.text
s = text3.text
if m >= 60 then
msgbox "分鐘數必須小於60!"
exit sub
end if
if s >= 60 then
msgbox "秒數必須小於60!"
exit sub
end if
timer1.enabled = trueend sub
private sub command2_click()timer1.enabled = falseend sub
private sub form_load()text1.text = ""
text2.text = ""
text3.text = ""
command1.caption = "開始"
command2.caption = "停止"
label1.caption = ""
timer1.interval = 1000timer1.enabled = falseend sub
private sub timer1_timer()dim r as string
if h <> 0 then
if m <> 0 then
if s = 0 then
m = m - 1
s = 59
else
s = s - 1
end if
else
if s <> 0 then
s = s - 1
else
h = h - 1
m = 59
s = 59
end if
end if
else
if m <> 0 then
if s = 0 then
m = m - 1
s = 59
else
s = s - 1
end if
else
if s <> 0 then
s = s - 1
else
label1.caption = "倒計時完成!"
timer1.enabled = falseend if
end if
end if
if h <> 0 or m <> 0 or s <> 0 thenr = cstr(h) & "小時" & cstr(m) & "分" & s & "秒"
label1.caption = r
end if
end sub
2樓:
新增乙個timer控制項。
dim a, b, c as integerprivate sub command1_click()a = text1.text
b = text2.text
c = text3.text
timer1.interval = 1000timer1.enabled = trueend sub
private sub command2_click()timer1.enabled = falselabel1.caption = "停止計時"
end sub
private sub form_load()timer1.enabled = falseend sub
private sub timer1_timer()label1.caption = a & ":" & b & ":" & c
if c = 0 then
if b = 0 then
if a = -1 then
timer1.enabled = falselabel1.caption = "倒計時完成"
else
c = c - 1
b = 59
c = 59
end if
else
b = b - 1
c = 59
end if
else
c = c - 1
end if
end sub
3樓:
public class jtime
inherits system.windows.forms.formdim t1, m1, s1
private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.
click
t1 = 60 * textbox1.texttimer1.enabled = trueend sub
private sub timer1_tick(byval sender as system.object, byval e as system.eventargs) handles timer1.
tick
t1 = t1 - 1
m1 = int(t1 / 60)
s1 = t1 mod 60
label3.text = m1 & "分" & s1 & "秒"
if t1 = 0 then
timer1.enabled = falselabel3.text = "倒計時完成"
end if
end sub
private sub button2_click(byval sender as system.object, byval e as system.eventargs) handles button2.
click
timer1.enabled = falseend sub
end class
4樓:曹昌裕
中華人民共和國民黨組織
5樓:匿名使用者
這用乙個timer就能實現了呀。
vb中怎樣製作乙個計時器? 能夠設定倒計時的時間,並進行倒計時
6樓:
1、開啟vb6.0,新建乙個工程,在窗體中新增三個命令按鈕,caption分別改為「設定倒計時」、「啟動倒計時」、「繼續」,將窗體form1的caption屬性改為「倒計時」,新增乙個計時器控制項,新增乙個文字框。
2、將文字框的text屬性清空,將字型font屬性調整為小四,便於觀察,將背景色屬性backcolor調為淺黃色。
3、雙擊「設定倒計時」命令按鈕,進入**編輯視窗。
4、雙擊「啟動倒計時」命令按鈕,進入**編輯視窗。
5、雙擊「計時器」控制項,進入**編輯視窗。
6、在**編輯視窗的通用段進行變數定義:dim h as integer, m as integer, s as integer '分別儲存時分秒dim a as integer。
8、關閉**視窗,按下f5執行程式,單擊「設定倒計時」命令按鈕,彈出輸入對話方塊,此時輸入分鐘數為1,確定。
9、單擊「啟動倒計時」命令按鈕,文字框顯示倒計時時間,並時刻變動,至此實現了倒計時功能。
7樓:天天過節
用到三個控制項:文字框(text1)、按鈕(command1)、計時器(timer1)
private sub command1_click()timer1.interval = 1000end sub
private sub timer1_timer()text1.text = val(text1.text) - 1if text1.
text < 1 thenmsgbox "時間到"
unload me
end if
end sub
8樓:弒神者是我
事先要在秒錶**調 enable屬性為false,interval屬性為1000
private sub command1_click()timer1.enabled = trueend sub
private sub timer1_timer()text1.text = val(text1.text) - 1if text1.
text < 1 thenmsgbox "時間到"
unload me
end if
end sub
9樓:匿名使用者
設定倒計時 開始時間t
for ,step -1
顯示 t-1s
next
怎麼用vb製作乙個倒計時?
10樓:
窗體中放置三個command、三個label、乙個timer控制項,在form_load過程中已經說明了控制項用途,其中label1是顯示分鐘數,label2是顯示秒數,**如下:
dim js as integer '這裡宣告了乙個全域性變數,儲存計時數
private sub command1_click()
timer1.enabled = false '停止計時
end sub
private sub command2_click()
timer1.enabled = true '繼續計時
end sub
private sub command3_click()
unload me '重新計時
form1.show
end sub
private sub form_load()
command1.caption = "暫停" '"暫停"按鈕
command2.caption = "繼續" '"繼續"按鈕
command3.caption = "重新計時" '"重新計時"按鈕
label3.caption = ":" '顯示":" 分隔符
timer1.enabled = true '使計時開始
timer1.interval = 1000 '計時間隔為1分鐘(1000毫秒)
js = 180 '計時數初始化,180秒即3分鐘
end sub
private sub timer1_timer()
dim f as integer, m as integer
if js > 0 then
js = js - 1
if js <= 30 then '在小於30秒後,標籤底色為紅色
label1.backcolor = &hff
label2.backcolor = &hff
label3.backcolor = &hff
end if
f = int(js / 60) '計算分鐘數
m = js - f * 60 '計算秒數
label1.caption = f '在label1標籤顯示分鐘數
label2.caption = m '在label2標籤顯示秒數
else
timer1.enabled = false '如果計時數小於或等於0,不再計時
end if
end sub
怎麼用VB製作倒計時,怎麼用VB製作一個倒計時?
窗體中放置三個command 三個label 一個timer控制元件,在form load過程中已經說明了控制元件用途,其中label1是顯示分鐘數,label2是顯示秒數,如下 dim js as integer 這裡宣告瞭一個全域性變數,儲存計時數 private sub command1 cl...
倒計時 的英文是,倒計時的英文翻譯
countdown 或count down 例句 宇宙飛船已在進行倒計時。the spaceship is already being counted down. count down 請問 十分鐘倒計時 用英文如何表達? ten minute countdown 或a ten minute cou...
作文 中考倒計時,中考倒計時 作文
高考指導鴨梨老師 說老實話,不想回答你這個問題,我比較不贊同初中生或小學生把題目直接放在網上求答案,不思考永遠不會進步。然而還是忍不住寫下一些,關於構思作文的建議 首先審題,這個題目看起來更適合選擇的體裁是側重抒情的散文,那麼形散而神不散是你要追求的目標,語言的優美和精緻是要重點考慮的。既然題目是中...