vb设计一个多功能计时器,时钟,秒表,倒计时功能,LED风格,程序启动时,首先进入时钟模式

秒表模式下,开始按钮按下之后变为暂停,回零无效。暂停按下后,变为继续... 秒表模式下,开始按钮按下之后变为暂停,回零无效。暂停按下后,变为继续 展开
 我来答
人文88
推荐于2016-10-18
知道答主
回答量:1
采纳率:0%
帮助的人:2.7万
展开全部
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"
Cls
Call 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
Cls
End 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
Cls
Call 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
Cls
Call Show_LED(picTimer, str)
Else
picTimer.Visible = False
Cls
frmTimer.Print "时间到"
Timer2.Enabled = False
End If
End Sub

Private Sub Timer3_Timer() '时钟显示过程
str = CStr(Now)
Call Show_LED(picTimer, str)
Cls
End 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
杭州励贝电液科技有限公司
2023-08-23 广告
设计比例控制器需要以下步骤:1. 确定控制系统的要求,例如控制对象的特性、控制范围、精度等。2. 选择合适的传感器,能够准确测量控制对象的相关参数,例如位置、速度、压力等。3. 选择合适的执行器,能够产生足够的控制作用,例如电缸、电动推杆等... 点击进入详情页
本回答由杭州励贝电液科技有限公司提供
weika50
2012-06-18
知道答主
回答量:17
采纳率:0%
帮助的人:4.7万
展开全部
现在有没有解决,如果解决了能不能给我发一下,谢谢,一定给积分
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
wangzhaoli
2012-06-13 · TA获得超过113个赞
知道小有建树答主
回答量:350
采纳率:0%
帮助的人:97.1万
展开全部
现在做晚不晚
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式