Alarm Clock

Topic Progress

We are going to create an alarm clock that loads the current time. You can set the alarm in the future with a message that is spoken when the alarm goes off





You will need:

  • 5 labels
  • 1 dateTimePicker
  • 1 button
  • 2 Timers



In Properties change the format by clicking the dropdown to time





Click on the Form and paste:

1
Timer2.Enabled = True

Click on the Button and paste:

1
2
Timer1.Enabled = True
Label5.Text = "Status:Alarm is set!"

Click on Timer1 and paste:

1
2
3
4
5
 If TimeOfDay = DateTimePicker1.Text Then      
     Dim voice = CreateObject("SAPI.spvoice"
     voice.speak(TextBox1.Text)
     Label5.Text = "Status:Alarm is not set!"
  End If

Click on Timer2 and paste:

1
 Label2.Text = TimeOfDay

Run the program

  1. Run the program
  2. Set the alarm to about 20 seconds in the future
  3. Type in a message
  4. The message should be spoken by the computer as the alarm

Code Challenge

  • Add an image of an alarm clock that appears when the alarm goes off (you can hide a pitcureBox to do this and add an image from Google
  • Get the background of the form to turn or flash red when the alarm goes off