《资料杂谈》秒表倒计时程序 免费试读
OptionExplicit
PrivateConstSRCCOPY=HCC0020
privatedeclaurefunctionbittlibgdi 32(ByValhdcDestAsLong、ByValXDestAsLong、ByValYDestAsLong、ByValnWidthAsLong、ByValnHeightAsLong、ByValhDCSrcAsLong、ByValxSrcAsLong、ByValySrcAsLong、ByValdwRopAsLong)AsLong
privatewitheventsmobjslumberasclasslumber
PrivatemobjProgBarAsclsProgressBar
PrivatemobjPieBarAsclsPieBar
PrivatemdTotalTimeAsDouble
PrivatemdCurrentTimeAsDouble
PrivatemdCurrentHoursAsLong
PrivatemdCurrentMinsAsLong
PrivatemdCurrentSecsAsDouble
PrivatembInterruptedAsBoolean
PrivateSubcmdStart _ Click()
OnErrorGoToErrHandler
DimsMsgAsString
IfcmdStart。Caption=StopThen
m中断=真
移动木材。唤醒
ExitSub
结束条件
EnsureDataisNumeric
txtHours。Text=Val(txtHours。正文)
txtMins。Text=Val(txtMins。正文)
txtSecs。Text=Val(txtSecs。正文)
ensurevaluessarewholenumbers
txtHours。Text=Int(txtHours。正文)
txtMins。Text=Int(txtMins。正文)
txtSecs。Text=Int(txtSecs。正文)
ValidateInputData
SelectCaseVal(txtHours。正文)
案例0
sMsg = Hourscannotbeanegativenumber!
GoToDisplayMsg
结束选择
SelectCaseVal(txtMins。正文)
案例0
sMsg = Minutescannotbeanegativenumber!
GoToDisplayMsg
CaseIs=60
sMsg = minutescannotbegreaterthanorequalto 60!
GoToDisplayMsg
结束选择
SelectCaseVal(txtSecs。正文)
案例0
sMsg = Secondscannotbeanegativenumber!
GoToDisplayMsg
CaseIs=60
sMsg = secondscannotbegreaterthanorequalto 60!
GoToDisplayMsg
结束选择
IfVal(txtHours。Text)=0AndVal(txtMins。Text)=0AndVal(txtSecs。text)= 0然后
sMsg = Pleaseinputcountdowntime!
GoToDisplayMsg
结束条件
显示消息:
IfLen(sMsg)0然后
MsgBoxsMsg,vbInformation+vbOKOnly,App。标题
ExitSub
结束条件
锁定输入箱
txtHours。锁定=真
txtMins。锁定=真
txtSecs。锁定=真
m中断=假
cmdStart。标题=停止
settoslumber每10毫秒
(这意味着statclsslumberwillputhethreadtosleepfor
10毫秒SATA timeuntilthetotaltimehaselapsed)
移动木材。SlumberInterval=10
calculatedtotalnumberofmilliseconds
mdTotalTime=(((Val(txtHours。Text)*60)+Val(txtMins。Text))*60)+Val(txtSecs。正文)
开始沉睡
移动木材。SlumberCLng(mdTotalTime*1000)
Resetformstate
cmdStart。标题=开始
IfNotmbInterruptedThen
呼叫显示(000.00.00.0000)
mobjProgBar。值=100
mobjPieBar。值=100
结束条件
解锁输入框
txtHours。锁定=假
txtMins。锁定=假
txtSecs。锁定=假
ExitSub
错误处理程序:
MsgBoxErr。说明,vbCritical+vbOKOnly,App。标题
末端接头
PrivateSubForm_L)
OnErrorGoToErrHandler
pbTextBuffer。BackColor=vbBlack
pbTextBuffer。清屏
pbTextBuffer。FontBold=True
pbTextBuffer。FontSize=24
pbTextBuffer。ForeColor=vbGreen
pbTextBuffer。ScaleMode =像素
pbTextBuffer。AutoRedraw = True
pbTextBuffer。可见=假
SetmobjSlumber=NewclsSlumber
SetmobjProgBar = NewclsProgressBar
SetmobjProgBar。图片框=图片1
mobjProgBar。BackColor=Picture1。背景色
SetmobjPieBar=NewclsPieBar
SetmobjPieBar。图片框=图片2
我。ScaleMode =像素
我。显示
mobjProgBar。值=100
mobjPieBar。值=100
多项活动
CallConvertTime
ExitSub
错误处理程序:
MsgBoxErr。说明,vbCritical+vbOKOnly,App。标题
末端接头
private subform _ unllcancelasinteger)
SetmobjSlumber = Nothing
SetmobjProgBar=Nothing
SetmobjPieBar =无
目标
末端接头
PrivateSubmobjSlumber _ sleep()
OnErrorGoToErrHandler
IfmobjSlumber。ElapsedMilliseconds0Then然后
mdCurrentTime = mdTotalTime-CDbl(mobjslumb。逝去毫秒/1000)
mobjProgBar。值=(100*(mobjSlumber。elapsed毫秒/(mdTotalTime*1000)))
mobjPieBar。Value=mobjProgBar。价值
其他
mobjProgBar。值=0
mobjPieBar。值=0
mdCurrentTime=mdTotalTime
结束条件
mdCurrentHours = Int(CStr(mdCurrentTime))3600
mdCurrentSecs = mdCurrentTime-(mdCurrentHours * 3600)
mdCurrentMins = Int(CStr(mdCurrentSecs))60
mdCurrentSecs = mdCurrentSecs-(mdCurrentMins * 60)
call display(Format $(mdCurrentHours,000)。格式$(mdCurrentMins,00)。格式$(mdCurrentSecs,00.0000))
ExitSub
错误处理程序:
呃。RaiseErr.Number,Err。Source,[frm count down . mobjslumber _ Slumber]Err。描述
末端接头
privateudisplay(TextAsString)
WithpbTextBuffer
。清屏
。CurrentX=0
。当前值=10
pbTextBuffer。打印文本
BitBltMe.hDC,。左,。顶,。ScaleWidth,。ScaleHeight,。hDC,0,0,SRCCOPY
结束于
末端接头
PrivateSubConvertTime()
call display(Format $(Val(txtHours。正文),000)。格式$(Val(txtMins。正文)、00)。格式$(Val(txtSecs。文本),00).0000)
末端接头
private subtext hours _ KeyUp(keycode as integer,ShiftAsInteger)
CallConvertTime
末端接头
PrivateSubtxtMins _ Change()
CallConvertTime
末端接头
PrivateSubtxtSecs _ Change()
CallConvertTime
末端接头