VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



A little clock that sits on your desktop

by Mike-Ejeet 9t9 (5 Submissions)
Category: Jokes/Humor
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This gives the code for a little arlarm clock that sits on your desktop. The soul purpose of this application is to give the current time. Very Simple.

Inputs
1 timer- Interval 500 and name timer 1

Rate A little clock that sits on your desktop

I(n the form itself enter this code:
Private Sub Form_Click()
  AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
  If AlarmTime = "" Then Exit Sub
  If Not IsDate(AlarmTime) Then
    MsgBox "The time you entered was not valid."
  Else                  ' String returned from InputBox is a valid time,
    AlarmTime = CDate(AlarmTime)    ' so store it as a date/time value in AlarmTime.
  End If
End Sub

**********In the timer enter this code:*****************
Private Sub Timer1_Timer()
Static AlarmSounded As Integer
  If lblTime.Caption <> CStr(Time) Then
    ' It's now a different second than the one displayed.
    If Time >= AlarmTime And Not AlarmSounded Then
      Beep
      MsgBox "Alarm at " & Time
      AlarmSounded = True
    ElseIf Time < AlarmTime Then
      AlarmSounded = False
    End If
    If WindowState = conMinimized Then
      ' If minimized, then update the form's Caption every minute.
      If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
    Else
      ' Otherwise, update the label Caption in the form every second.
      lblTime.Caption = Time
    End If
  End If
End Sub


Download this snippet    Add to My Saved Code

A little clock that sits on your desktop Comments

No comments have been posted about A little clock that sits on your desktop. Why not be the first to post a comment about A little clock that sits on your desktop.

Post your comment

Subject:
Message:
0/1000 characters