PDA

View Full Version : using alarm



lior03
04-11-2006, 02:03 PM
hello
the following macros...

Sub timerMsg()
Dim alertTime
MsgBox "The alarm will go off in 15 seconds!"
alertTime = Now + TimeValue("00:00:15")
Application.OnTime alertTime, "msg5"
End Sub
Sub msg5()
MsgBox " 15 Seconds is up! "
Beep
End Sub


allow the user to be reminded that 15 second have passed.
how can i used it to allow the user select his own time interval?.how can i add an inputbox so he can select by himself when to be reminded?
thanks

geekgirlau
04-11-2006, 05:37 PM
Sub timerMsg()
Dim alertTime As Date
Dim strSecond As String
Dim strMinute As String
Dim strHour As String
Dim strTime As String

strSecond = InputBox("Enter the time interval (in seconds)")

If strSecond <> "" Then
' have they entered an amount >60 seconds? >60 minutes?
Select Case Val(strSecond)
Case Is > 3600
strHour = Int(Val(strSecond) / 3600)
strSecond = strSecond - (strHour * 3600)
strMinute = Int(Val(strSecond) / 60)
strSecond = strSecond - (strMinute * 60)

Case Is > 60
strMinute = Int(Val(strSecond) / 60)
strSecond = strSecond - (strMinute * 60)

Case Else
strMinute = "00"
strHour = "00"
End Select

strTime = strHour & " hour(s), " & _
strMinute & " minute(s) and " & _
strSecond & " second(s)"

MsgBox "The alarm will go off in " & strTime & "!"

alertTime = Now + TimeValue(Format(strHour, "00") & ":" & _
Format(strMinute, "00") & ":" & _
Format(strSecond, "00"))

Do Until Now() >= alertTime
DoEvents
Loop

msg5 strTime
End If
End Sub

Sub msg5(strTime As String)
MsgBox strTime & " is up! "
Beep
End Sub