-

来自「visualbasic学习材料及开发源代码」· 代码 · 共 82 行

TXT
82
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   2805
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   2805
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   240
      Top             =   1800
   End
   Begin VB.Label LblTip 
      Caption         =   "当前系统时间:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   1200
      Width           =   1695
   End
   Begin VB.Label LblTimer 
      Alignment       =   2  'Center
      BorderStyle     =   1  'Fixed Single
      Caption         =   "LblTimer"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1800
      TabIndex        =   0
      Top             =   1080
      Width           =   2535
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim alarm_time As String
Private Sub Form_Click()
tempstring$ = InputBox$("enter alarm time(24:00:00):")
If tempstring$ <> "" Then
  alarm_time = tempstring$

End If

End Sub

Private Sub Timer1_Timer()
Static alarmsounded As Boolean
LblTimer.Caption = Time$
If alarm_time = "" Then Exit Sub
If Time$ >= alarm_time And Not alarmsounded Then
    soundname$ = App.Path + "\ringin.wav"
    X% = sndplaysound(soundname, snd_async Or snd_nodefault)
    MsgBox "time out!"
    alarmsounded = True
ElseIf Time$ < alarm_time Then
   alarmsounded = False
End If
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?