Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21273

[RESOLVED] alarm ringing in vb6

$
0
0
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

Viewing all articles
Browse latest Browse all 21273

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>