home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09964.iso / program / vxlcd12.zip / Alarm.frm next >
Text File  |  1996-07-20  |  4KB  |  135 lines

  1. VERSION 4.00
  2. Begin VB.Form AlarmForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Alarm Clock"
  5.    ClientHeight    =   1065
  6.    ClientLeft      =   3750
  7.    ClientTop       =   4020
  8.    ClientWidth     =   2685
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   8.25
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    Height          =   1470
  19.    Icon            =   "Alarm.frx":0000
  20.    Left            =   3690
  21.    LinkTopic       =   "Form2"
  22.    LockControls    =   -1  'True
  23.    MaxButton       =   0   'False
  24.    ScaleHeight     =   71
  25.    ScaleMode       =   3  'Pixel
  26.    ScaleWidth      =   179
  27.    Top             =   3675
  28.    Width           =   2805
  29.    Begin VB.CommandButton Command1 
  30.       Caption         =   "Set Alarm"
  31.       BeginProperty Font 
  32.          name            =   "MS Sans Serif"
  33.          charset         =   0
  34.          weight          =   400
  35.          size            =   8.25
  36.          underline       =   0   'False
  37.          italic          =   0   'False
  38.          strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   315
  41.       Left            =   120
  42.       TabIndex        =   1
  43.       Top             =   660
  44.       Width           =   2415
  45.    End
  46.    Begin VB.Timer Timer1 
  47.       Interval        =   500
  48.       Left            =   660
  49.       Top             =   60
  50.    End
  51.    Begin VB.PictureBox picTime 
  52.       Height          =   435
  53.       Left            =   120
  54.       ScaleHeight     =   375
  55.       ScaleWidth      =   2355
  56.       TabIndex        =   0
  57.       Top             =   120
  58.       Width           =   2415
  59.    End
  60. End
  61. Attribute VB_Name = "AlarmForm"
  62. Attribute VB_Creatable = False
  63. Attribute VB_Exposed = False
  64. ' Sample program that comes with VB.
  65. ' Adapted for VBMaxLCD.dll by Mike Stanley
  66.  
  67. Option Explicit
  68. Dim Readout As New CLCD
  69. Dim AlarmTime
  70.  
  71. Const conMinimized = 1
  72.  
  73.  
  74. Private Sub Form_Load()
  75.      
  76.     With Readout
  77.         .Alignment = gnCENTER
  78.         .ShowUnlitSegments = False
  79.         .ForeColor = &H8080&
  80.         Set .Container = picTime
  81.     End With
  82.  
  83.     AlarmTime = ""
  84.     
  85. End Sub
  86.  
  87. Private Sub Form_Resize()
  88.     If WindowState = conMinimized Then      ' If form is minimized, display the time in a caption.
  89.         SetCaptionTime
  90.     Else
  91.         Caption = "Alarm Clock"
  92.     End If
  93. End Sub
  94.  
  95. Private Sub SetCaptionTime()
  96.     Caption = Format(Time, "Medium Time")   ' Display time using medium time format.
  97. End Sub
  98.  
  99. Private Sub Form_Unload(Cancel As Integer)
  100.     Set Readout = Nothing
  101.     Set AlarmForm = Nothing
  102. End Sub
  103.  
  104. Private Sub Timer1_Timer()
  105. Static AlarmSounded As Integer
  106.     If Readout.Caption <> CStr(Time) Then
  107.         ' It's now a different second than the one displayed.
  108.         If Time >= AlarmTime And Not AlarmSounded Then
  109.             Beep
  110.             MsgBox "Alarm at " & Time
  111.             AlarmSounded = True
  112.         ElseIf Time < AlarmTime Then
  113.             AlarmSounded = False
  114.         End If
  115.         If WindowState = conMinimized Then
  116.             ' If minimized, then update the form's Caption every minute.
  117.             If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
  118.         Else
  119.             ' Otherwise, update the label Caption in the form every second.
  120.             Readout.Caption = Time
  121.         End If
  122.     End If
  123. End Sub
  124.  
  125. Private Sub Command1_Click()
  126.     AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
  127.     If AlarmTime = "" Then Exit Sub
  128.     If Not IsDate(AlarmTime) Then
  129.         MsgBox "The time you entered was not valid."
  130.     Else                                    ' String returned from InputBox is a valid time,
  131.         AlarmTime = CDate(AlarmTime)        ' so store it as a date/time value in AlarmTime.
  132.     End If
  133. End Sub
  134.  
  135.