Alarm clock


This code shows how to create alarm clock using windows application

Description



Create a windows form of desired dimensions.Add a label lblTime to display current time,date picker dtpTime,timer control tmrNewTime and a check box
chkAlarm.If the check box is checked and current time displayed in label lblTime matches with the time displayed in date picker dtpTime then play a
sound.The code is as,

Public Class frmAlarmClock
Private Sub tmrNewTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrNewTime.Tick
lblTime.Text = DateTime.Now.ToLongTimeString
If chkAlarm.Checked = True Then
If dtpTime.Text = lblTime.Text Then
My.Computer.Audio.Play(My.Resources.ringout, AudioPlayMode.BackgroundLoop)
End If
Else
My.Computer.Audio.Stop()
End If
End Sub

Private Sub frmAlarmClock_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
My.Computer.Audio.Stop()
End Sub

Private Sub frmAlarmClock_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblTime.Text = DateTime.Now.ToLongTimeString
End Sub
End Class


Comments

Author: amol00718 Jan 2010 Member Level: Silver   Points : 0

Nice code.
It's working.

Author: Alwyn Duraisingh19 Jan 2010 Member Level: Gold   Points : 1

Alarm is working fine,

but it would be nice if it has the option

to play atleast a song. so that we can have a happy beginning of a day.

Author: Dilip19 Jan 2010 Member Level: Gold   Points : 1

Alwyn,
Check the function paly from "My.Computer.Audio.Play".You can also specify other audio clip also.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: