home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / wtest / micrsoft / vbasic4 / vb4-4.cab / alarm.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-08-15  |  3.1 KB  |  96 lines

  1. VERSION 4.00
  2. Begin VB.Form AlarmForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Alarm Clock"
  5.    ClientHeight    =   780
  6.    ClientLeft      =   1230
  7.    ClientTop       =   1635
  8.    ClientWidth     =   3135
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   1
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   1185
  19.    Icon            =   "ALARM.frx":0000
  20.    Left            =   1170
  21.    LinkTopic       =   "Form2"
  22.    MaxButton       =   0   'False
  23.    ScaleHeight     =   780
  24.    ScaleWidth      =   3135
  25.    Top             =   1290
  26.    Width           =   3255
  27.    Begin VB.Timer Timer1 
  28.       Interval        =   500
  29.       Left            =   2640
  30.       Top             =   120
  31.    End
  32.    Begin VB.Label lblTime 
  33.       BeginProperty Font 
  34.          name            =   "MS Sans Serif"
  35.          charset         =   1
  36.          weight          =   700
  37.          size            =   12
  38.          underline       =   0   'False
  39.          italic          =   0   'False
  40.          strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   495
  43.       Left            =   120
  44.       TabIndex        =   0
  45.       Top             =   120
  46.       Width           =   2415
  47.    End
  48. Attribute VB_Name = "AlarmForm"
  49. Attribute VB_Creatable = False
  50. Attribute VB_Exposed = False
  51. Option Explicit
  52. Dim AlarmTime
  53. Const conMinimized = 1
  54. Private Sub Form_Click()
  55.     AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
  56.     If AlarmTime = "" Then Exit Sub
  57.     If Not IsDate(AlarmTime) Then
  58.         MsgBox "The time you entered was not valid."
  59.     Else                                    ' String returned from InputBox is a valid time,
  60.         AlarmTime = CDate(AlarmTime)        ' so store it as a date/time value in AlarmTime.
  61.     End If
  62. End Sub
  63. Private Sub Form_Load()
  64.     AlarmTime = ""
  65. End Sub
  66. Private Sub Form_Resize()
  67.     If WindowState = conMinimized Then      ' If form is minimized, display the time in a caption.
  68.         SetCaptionTime
  69.     Else
  70.         Caption = "Alarm Clock"
  71.     End If
  72. End Sub
  73. Private Sub SetCaptionTime()
  74.     Caption = Format(Time, "Medium Time")   ' Display time using medium time format.
  75. End Sub
  76. Private Sub Timer1_Timer()
  77. Static AlarmSounded As Integer
  78.     If lblTime.Caption <> CStr(Time) Then
  79.         ' It's now a different second than the one displayed.
  80.         If Time >= AlarmTime And Not AlarmSounded Then
  81.             Beep
  82.             MsgBox "Alarm at " & Time
  83.             AlarmSounded = True
  84.         ElseIf Time < AlarmTime Then
  85.             AlarmSounded = False
  86.         End If
  87.         If WindowState = conMinimized Then
  88.             ' If minimized, then update the form's Caption every minute.
  89.             If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
  90.         Else
  91.             ' Otherwise, update the label Caption in the form every second.
  92.             lblTime.Caption = Time
  93.         End If
  94.     End If
  95. End Sub
  96.