1樓:胡春磊
option explicit
public t as integer, str asstring
public h as integer, m asinteger, s as integer
private subshow_led(pictimer as picturebox, str as string)
'顯示**的通用過程
dim s as string * 1
dim pos as integer
dim n as integer
dim i as integer
for i = 1 to len(str)
s = mid(str, i, 1)
n = -1
select case s
case "0" to "9"
n = cint(s)
case ":"
n = 10
case "-"
n = 11
case "."
n = 12
case "a", "a"
n = 13
case "p", "p"
n = 14
case " "
n = 15
end select
if n <> -1 then
pictimer.paintpicturepctimer.graphiccell(n), pos, 0
pos = pos + 300
end if
next
end sub
private subcmdrestart_click() '秒錶的回零
h = 0
m = 0
s = 0
str = ""
cmdstart.caption = "開始"
timer1.enabled = false: str ="00:00:00"
clscall show_led(pictimer, str)
end sub
private sub cmdstart_click()'秒錶的開始和暫停控制
if cmdstart.caption = "開始" then
h = 0
m = 0
s = 0
cmdstart.caption = "暫停"
timer1.enabled = true
cmdrestart.enabled = false
exit sub
elseif cmdstart.caption = "暫停" then
cmdstart.caption = "繼續"
timer1.enabled = false
cmdrestart.enabled = true
exit sub
else
cmdstart.caption = "暫停"
timer1.enabled = true
cmdrestart.enabled = false
exit sub
end if
end sub
private sub form_load() '窗體載入
call mnuclock_click
end sub
private sub mnuclock_click()'時鐘
pictimer.cls
me.cls
timer1.enabled = false
timer2.enabled = false
cmdstart.visible = false
cmdrestart.visible = false
frmtimer.caption = "時鐘"
timer3.enabled = true
pictimer.visible = true
clsend sub
private submnucuntdwnclock_click() '倒計時
pictimer.cls
me.cls
timer1.enabled = false
timer3.enabled = false
cmdstart.visible = false
cmdrestart.visible = false
frmset.visible = true
frmtimer.caption = "倒計時鐘"
pictimer.visible = true
end sub
private sub mnuexit_click()'退出選項
unload frmtimer: unload frmset
end sub
private sub mnustopwatch_click()'秒錶
pictimer.cls
me.cls
timer1.enabled = false
timer2.enabled = false
timer3.enabled = false
cmdstart.visible = true
cmdrestart.visible = true
frmtimer.caption = "秒錶"
pictimer.visible = true
end sub
private sub timer1_timer() '秒錶計時過程
str = ""
s = s + 1
if s = 100 then '秒錶數字顯示的處理
s = 0
m = m + 1
if m = 60 then
m = 0
h = h + 1
if h = 24 then
h = 0
end if
end if
end if
if h < 10 then '數字顯示格式的處理
str = str & 0 & h
else: str = str & h
end if
if m < 10 then
str = str & ":" & 0 &m
else: str = str & ":" & m
end if
if s < 10 then
str = str & ":" & 0 &s
else: str = str & ":" & s
end if
clscall show_led(pictimer, str)
end sub
private subtimer2_timer() '倒計時計時過程
pictimer.cls
str = ""
t = h * 3600 + m * 60 + s
if t >= 1 then
s = s - 1
if s = -1 then
s = 59
m = m - 1
end if
if m = -1 then
m = 59
h = h - 1
end if
if h < 10 then
str = str & "0" & h
else
str = str & ":" & h
end if
if m < 10 then
str = str & ":" &"0" & m
else
str = str & ":" & m
end if
if s < 10 then
str = str & ":" &"0" & s
else
str = str & ":" & s
end if
clscall show_led(pictimer, str)
else
pictimer.visible = false
clsfrmtimer.print "時間到"
timer2.enabled = false
end if
end sub
private sub timer3_timer() '時鐘顯示過程
str = cstr(now)
call show_led(pictimer, str)
clsend sub
option explicit
private subcmdcuntstart_click()
frmtimer.h = val(txtinput(0))
frmtimer.m = val(txtinput(1))
frmtimer.s = val(txtinput(2))
if frmtimer.h + frmtimer.m + frmtimer.s = 0then
call msgbox("輸入錯誤,請重新輸入", 48,"多功能計時器")
else
frmtimer.timer2.enabled = true
unload frmset
end if
end sub
2樓:佔成
我也求這個,快被逼瘋了,樓主還有答案嗎(눈_눈)
vb設計一個多功能計時器,時鐘,秒錶,倒計時功能,led風格,程式啟動時,首先進入時鐘模式
3樓:人文
frmtimer窗體控制元件:
commandbutton * 2
picturebox * 1
pictureclip(注:**剪下控制元件) * 1
timer * 3
(注:此處只給出了控制元件型別,控制元件名祥見**)
frmtimer 的**
option explicit
public t as integer, str as string
public h as integer, m as integer, s as integer
private sub show_led(pictimer as picturebox, str as string)
'顯示**的通用過程
dim s as string * 1
dim pos as integer
dim n as integer
dim i as integer
for i = 1 to len(str)
s = mid(str, i, 1)
n = -1
select case s
case "0" to "9"
n = cint(s)
case ":"
n = 10
case "-"
n = 11
case "."
n = 12
case "a", "a"
n = 13
case "p", "p"
n = 14
case " "
n = 15
end select
if n <> -1 then
pictimer.paintpicture pctimer.graphiccell(n), pos, 0
pos = pos + 300
end if
next
end sub
private sub cmdrestart_click() '秒錶的回零
h = 0
m = 0
s = 0
str = ""
cmdstart.caption = "開始"
timer1.enabled = false: str = "00:00:00"
clscall show_led(pictimer, str)
end sub
private sub cmdstart_click() '秒錶的開始和暫停控制
if cmdstart.caption = "開始" then
h = 0
m = 0
s = 0
cmdstart.caption = "暫停"
timer1.enabled = true
cmdrestart.enabled = false
exit sub
elseif cmdstart.caption = "暫停" then
cmdstart.caption = "繼續"
timer1.enabled = false
cmdrestart.enabled = true
exit sub
else
cmdstart.caption = "暫停"
timer1.enabled = true
cmdrestart.enabled = false
exit sub
end if
end sub
private sub form_load() '窗體載入
call mnuclock_click
end sub
private sub mnuclock_click() '時鐘
pictimer.cls
me.cls
timer1.enabled = false
timer2.enabled = false
cmdstart.visible = false
cmdrestart.visible = false
frmtimer.caption = "時鐘"
timer3.enabled = true
pictimer.visible = true
clsend sub
private sub mnucuntdwnclock_click() '倒計時
pictimer.cls
me.cls
timer1.enabled = false
timer3.enabled = false
cmdstart.visible = false
cmdrestart.visible = false
frmset.visible = true
frmtimer.caption = "倒計時鐘"
pictimer.visible = true
end sub
private sub mnuexit_click() '退出選項
unload frmtimer: unload frmset
end sub
private sub mnustopwatch_click() '秒錶
pictimer.cls
me.cls
timer1.enabled = false
timer2.enabled = false
timer3.enabled = false
cmdstart.visible = true
cmdrestart.visible = true
frmtimer.caption = "秒錶"
pictimer.visible = true
end sub
private sub timer1_timer() '秒錶計時過程
str = ""
s = s + 1
if s = 100 then '秒錶數字顯示的處理
s = 0
m = m + 1
if m = 60 then
m = 0
h = h + 1
if h = 24 then
h = 0
end if
end if
end if
if h < 10 then '數字顯示格式的處理
str = str & 0 & h
else: str = str & h
end if
if m < 10 then
str = str & ":" & 0 & m
else: str = str & ":" & m
end if
if s < 10 then
str = str & ":" & 0 & s
else: str = str & ":" & s
end if
clscall show_led(pictimer, str)
end sub
private sub timer2_timer() '倒計時計時過程
pictimer.cls
str = ""
t = h * 3600 + m * 60 + s
if t >= 1 then
s = s - 1
if s = -1 then
s = 59
m = m - 1
end if
if m = -1 then
m = 59
h = h - 1
end if
if h < 10 then
str = str & "0" & h
else
str = str & ":" & h
end if
if m < 10 then
str = str & ":" & "0" & m
else
str = str & ":" & m
end if
if s < 10 then
str = str & ":" & "0" & s
else
str = str & ":" & s
end if
clscall show_led(pictimer, str)
else
pictimer.visible = false
clsfrmtimer.print "時間到"
timer2.enabled = false
end if
end sub
private sub timer3_timer() '時鐘顯示過程
str = cstr(now)
call show_led(pictimer, str)
clsend sub
frmtimer窗體控制元件:
text * 3
commandbuton * 1
label * 3
(注:控制元件名稱參照**)
frmset 的**
option explicit
private sub cmdcuntstart_click()
frmtimer.h = val(txtinput(0))
frmtimer.m = val(txtinput(1))
frmtimer.s = val(txtinput(2))
if frmtimer.h + frmtimer.m + frmtimer.s = 0 then
call msgbox("輸入錯誤,請重新輸入", 48, "多功能計時器")
else
frmtimer.timer2.enabled = true
unload frmset
end if
end sub
你好,我想問一下你暈車的事,想問一下暈車怎麼辦?
其實最好不要吃暈車藥,暈車藥會讓人暈暈欲睡,是藥三分毒嘛!我以前坐車暈車特別厲害,聞到氣油味就忍不住想吐,跟本不能坐車,後來每天早上起來跑步,連續堅持跑了三個月,效果果然不同凡響!坐幾個小時的車基本沒問題啦!我這些年暈車總結出一套經驗 1 上車不能看書 發簡訊 看車上的電視等注意力比較集中的事情。2...
你好,我想問下你借到錢了嗎,你好,我想問一下怎樣才能借到錢?
金丹期 第一老子沒有借錢的習慣,第二老子永遠不會在借錢出去 你好,我想問一下怎樣才能借到錢? 郎君別朝三暮四 需要 家 qq 聊 你好,我想問下你可以借錢嗎? 超級無敵 我這裡可以借錢給你沒有任何問題 年齡18以上,手機號實名六個月以上看主 業 來! 我這裡可以 怎樣聯絡你呢?你好我是被騙了十幾萬的...
你好我想問一下工傷賠償,你好 我想問一下零時工工傷賠償是怎麼算的
第三十七條 職工因工緻殘被鑑定為七級至十級傷殘的,享受以下待遇 一 從工傷保險 按傷殘等級支付一次性傷殘補助金,標準為 七級傷殘為13個月的本人工資,八級傷殘為11個月的本人工資,九級傷殘為9個月的本人工資,十級傷殘為7個月的本人工資 二 勞動 聘用合同期滿終止,或者職工本人提出解除勞動 聘用合同的...