VBA/Excel/Access/Word/Date Functions/TimeValue

Материал из VB Эксперт
Версия от 12:48, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Program an event for .m.:

 
Sub main()
    Application.OnTime TimeValue("3:00:00 pm"), "DisplayAlarm"
End Sub
Sub DisplayAlarm()
    Beep
    MsgBox "Wake up. It"s time for your afternoon break!"
End Sub



Scheduling a Verbal Reminder

 
Sub ScheduleSpeak()
    Application.OnTime EarliestTime:=TimeValue("9:14 AM"), Procedure:="RemindMe"
End Sub
Sub RemindMe()
    Application.Speech.Speak Text:="meeting."
End Sub



TimerValue function returns time value

 
Sub TimeValueDemo()
    MsgBox TimeValue("00:00:02")
End Sub



TimeValue("9:00") returns AM

 
Sub timeValueDemo()
    Debug.Print timeValue("9:00")
End Sub



TimeValue(time) returns A Variant/Date containing the time for time

 
Sub dateDemo15()
   Debug.Print timeValue(Now)
End Sub



To schedule an event relative to the current time - for example, 20 minutes from now

 
Sub Main()
    Application.OnTime Now + TimeValue("00:20:00"), "DisplayAlarm"
End Sub
Sub DisplayAlarm()
    Beep
    MsgBox "Wake up. It"s time for your afternoon break!"
End Sub