Simple Alarm Clock using Visual Basic.Net

In this tutorial, we're going to create a simple alarm clock. This alarm clock can be used to wake a person in at a specific time. To start with this application, open visual basic and create a new project and name it as “Alarm Clock”. The application when finished, it looks like as shown below.
Next, add five labels,and name the label1 as “lblcurtime” and label2 as “lblstatus” then,set the text property of the other label as “Current Time”, “Alarm Time” and “Message”. Add a Datetimpicker, then set it into “Time” format. Then add a textbox and a Button, after this rename the textbox1 as “txtmsg” and the button1 as “btnsetalarm”. And lastly add two timer.
This time, we will add functionality to our application. First double click the “timer1” and add the following code:
This code will simply check if the current settings of DateTimePicker1 match the Time of the day and the time is based on your local machine. So if match, it performs the following statements.
  1. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  2. If TimeOfDay = DateTimePicker1.Text Then
  3. 'This will instantinize a new "voice" for this app to speak through
  4. Dim voice = CreateObject("SAPI.spvoice")
  5. 'what the content of txtmsg will be passed to voice.speak
  6.  
  7. voice.speak(TextBox1.Text)
  8. lblstatus.Text = "Status:Alarm is not set!"
  9. End If
  10.  
  11. End Sub
Then, double click the “timer2” and add the following code:
This will display the current time based on the local machine.
  1. lblcurtime.Text = TimeOfDay
Next on the “form1_load” add the following code:
  1. Timer2.Enabled = True
And finally on the “btnsetalarm” button add the following code:
It enables the timer1 and set the alarm clock.

Timer1.Enabled = True
lblstatus.Text = "Status:Alarm is set!"
This time you can now try testing your program by pressing “F5”.

Related Posts:

  • PHP Database Access: Are You Doing It Correctly? What? It's possible that, at this point, the only thought in your mind is, "What the heck is PDO?" Well, it's one of PHP's three available APIs for connecting to a MySQL database. "Three," you say? Yes; many folks don't kno… Read More
  • 50 Excellent Adobe After Effect Tutorials #1 Fume FX Resource online Master Fire, Pyro & Hollywood FX Adobe After Effects is a digital motion graphics and compositing software. Its main purpose is for film and video post-production. With Adobe After Effec… Read More
  • Android Login activity with MySQL database connection Here I'm going to create a simple Android log in application  which can post data to a java web service and read data from MySQL database using a java web service to authenticate the user. Tested on Android 2.2. … Read More
  • Illustrator tutorial video full set Download Part 1:    Embedupload    Direct Link Download Part 2:    Embedupload    Direct Link Download Part 2:    Embedu… Read More
  • php validation script Validating User Input Validating user input in PHP By Kevin Waterson Contents Never trust user Input. Where do I begin Checking? How do I check my strings? How do I validate a number? Can I validate an email addres… Read More

0 ulasan: