Timer issue

NightShade01

Member
Joined
Jul 7, 2006
Messages
5
Programming Experience
1-3
Hey all I'm trying to create a simple little alarm clock app that will just play a sound when the alarm time is set. my prob is that once i get the user to set the alarm time the alarm never goes off at the time.

Here is what i have so far...

PublicSub alarmOn()

If (alarmState = True) Then
If (hours = TimeOfDay.Hour And mins = TimeOfDay.Minute) Then
PlaySound()
EndIf
Else
MsgBox("Please set the alarm time first.", , "Alarm Not Set")
EndIf

EndSub
PrivateSub lblSet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblSet.Click
Dim num1 AsDouble
Dim num2 AsDouble
num1 = System.Convert.ToDouble(txthours.Text)
num2 = System.Convert.ToDouble(txtmins.Text)
If ((num1 > 0) And (num1 <= 12)) And ((num2 >= 0) And (num2 <= 59)) Then
hours = num1
mins = num2
Else
MsgBox("Time not set in the right format. Example: 08:12 ", , )
EndIf
lblSet.Hide()
txthours.Hide()
txtmins.Hide()
EndSub



suggestions.....?
 
why download and unzip for 17 lines of code?

Here's for the people that don't want to download a zip file, unzip it, then start VS just to get 17 lines of code:

You'll need a form with a Label named Label1 and a System.Windows.Forms.Timer named Timer1
VB.NET:
'just don't forget to replace comments with present values

    Private cdTime As Integer = 10 '360
    Private cdDay As Integer = 4 '86400

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        cdDay -= 1
        Label1.Text = cdTime & " days remaining"
        If cdDay <= 0 Then
            cdTime -= 1
            cdDay = 4 '86400
        End If
        If cdTime <= 0 Then
            Timer1.Dispose()
            Label1.Text = "360 days have passed"
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = String.Empty
    End Sub
 
Back
Top