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

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

Program an event for .m.:

   <source lang="vb">

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

</source>
   
  


Scheduling a Verbal Reminder

   <source lang="vb">

Sub ScheduleSpeak()

   Application.OnTime EarliestTime:=TimeValue("9:14 AM"), Procedure:="RemindMe"

End Sub Sub RemindMe()

   Application.Speech.Speak Text:="meeting."

End Sub

</source>
   
  


TimerValue function returns time value

   <source lang="vb">

Sub TimeValueDemo()

   MsgBox TimeValue("00:00:02")

End Sub

</source>
   
  


TimeValue("9:00") returns AM

   <source lang="vb">

Sub timeValueDemo()

   Debug.Print timeValue("9:00")

End Sub

</source>
   
  


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

   <source lang="vb">

Sub dateDemo15()

  Debug.Print timeValue(Now)

End Sub

</source>
   
  


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

   <source lang="vb">

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

</source>