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 = "vb开始按钮代码继续"
    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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。