trying to create a program which set up an alarm but it shows an error :- run-time error ,error 6 also before it was showing another error but somehow correct it
following is the coding i used....:confused:
Option Explicit
Dim NoSeconds As Integer, TimePassed As Integer
Private Sub cmdSet_Click()
Dim Today As Date, dt As Date, tm As Date, dtStr As String
If (Val(txtHH.Text) >= 0 And Val(txtHH.Text) < 24) Then
If (Val(txtMM.Text) >= 0 And Val(txtMM.Text) < 60) Then
If (Val(txtSS.Text) >= 0 And Val(txtSS.Text) < 60) Then
Today = Now
dtStr = Date$ + " " + txtHH + ":" + txtMM + ":" + txtSS
dt = dtStr
tm = Format(dtStr, "mm/dd/yy hh:mm:ss am/pm")
NoSeconds = Abs(DateDiff("s", Today, tm))
TimePassed = 0
Else
MsgBox "Invalid Time--Invalid seconds"
End If
MsgBox "Invalid Time--Invalid minutes"
End If
MsgBox "Invalid Time--Invalid hours"
End If
End Sub
Private Sub time1_Timer()
Dim a As Integer
TimePassed = TimePassed + 1
If (TimePassed = NoSeconds) Then
lblMessage = "Now Alarm is ringing"
For a = 1 To 50
Beep
Next a
End If
End Sub
following is the coding i used....:confused:
Option Explicit
Dim NoSeconds As Integer, TimePassed As Integer
Private Sub cmdSet_Click()
Dim Today As Date, dt As Date, tm As Date, dtStr As String
If (Val(txtHH.Text) >= 0 And Val(txtHH.Text) < 24) Then
If (Val(txtMM.Text) >= 0 And Val(txtMM.Text) < 60) Then
If (Val(txtSS.Text) >= 0 And Val(txtSS.Text) < 60) Then
Today = Now
dtStr = Date$ + " " + txtHH + ":" + txtMM + ":" + txtSS
dt = dtStr
tm = Format(dtStr, "mm/dd/yy hh:mm:ss am/pm")
NoSeconds = Abs(DateDiff("s", Today, tm))
TimePassed = 0
Else
MsgBox "Invalid Time--Invalid seconds"
End If
MsgBox "Invalid Time--Invalid minutes"
End If
MsgBox "Invalid Time--Invalid hours"
End If
End Sub
Private Sub time1_Timer()
Dim a As Integer
TimePassed = TimePassed + 1
If (TimePassed = NoSeconds) Then
lblMessage = "Now Alarm is ringing"
For a = 1 To 50
Beep
Next a
End If
End Sub