Alarm Clock with Sound Message in VB.NET

In this tutorial, we will make a program that has an alarm clock function with sound message using vb.net. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add two Timers named Timer2 for displaying the current time and Timer1 for displaying the time to be alarmed. Insert DateTimePicker named DateTimePicker1 to be used as getting the alarmed time, one TextBox named TextBox1 for inputting a message for the alarm, two Labels named Label1 for displaying if the alarm clock is set and lblCurtime for displaying the current time in this label, and one Button named Button1 for the setup of the time to be alarmed. You must design your interface like this: design 3. In Timer2_Tick control, put this code below.
  1. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  2. lblCurtime.Text = TimeOfDay
  3. End Sub
The label named lblCurtime in Timer2 displays the current time of the day. This TimeOfDay property gets the time of day for this instance and will display to this label. 4. In Timer1_Tick control, put this code below.
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If the current time is equal to the alarmed time in DateTimePicker.  If TimeOfDay = DateTimePicker1.Text Then This will instantinize a new "voice" for this to speak through  Dim voice = CreateObject("SAPI.spvoice") What the content of message in textbox1 will be passed to voice.speak      voice.speak(TextBox1.Text) After being alarmed the status will be going back to not set.
  1. lblStatus.Text = "Alarm is not set!"
  2. End If
5. In our Form1_Load, put this code below.
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. Timer2.Enabled = True
  3. End Sub
This will display the current time when loading the form. 6. In our Button1_Click for the setup of the alarm, put this code below.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetAlarm.Click
  2. Timer1.Enabled = True
  3. lblStatus.Text = "Alarm is set!"
  4. End Sub
Timer1 is enabled because we have set the time of the alarmed time to be equal to the current time and will display to the user that time is now set! Output: output Download the source code below and try it! :) For more inquiries just contact my number or e-mail below. Best Regards, Engr. Lyndon R. Bermoy IT Instructor/System Developer/Android Developer Mobile: 09488225971 Telephone: 826-9296 E-mail:[email protected] Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky Visit my page on Facebook at: https://www.facebook.com/BermzISware

Add new comment