VBA/Excel/Access/Word/Date Functions/DateValue

Материал из VB Эксперт
Перейти к: навигация, поиск

DateValue(date) returns a Variant/Date containing the specified date

   <source lang="vb">

Sub dateDemo4()

  Debug.Print dateValue("July 2, 1971")

End Sub

</source>
   
  


DateValue("Nov, 23 04") returns 4

   <source lang="vb">

Sub dateValueDemo()

   Debug.Print dateValue("Nov, 23 04")

End Sub

</source>
   
  


Use the OnTime method to run a VBA procedure on a particular day: runs the DisplayAlarm procedure at .m. on December:

   <source lang="vb">

Sub Main() Application.OnTime DateValue("12/31/2007 5:00 pm"), "DisplayAlarm" End Sub Sub DisplayAlarm()

   Beep
   MsgBox "Wake up. It"s time for your afternoon break!"

End Sub

</source>