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

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

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

Sub dateDemo4()
   Debug.Print dateValue("July 2, 1971")
End Sub

DateValue("Nov, 23 04") returns 4

Sub dateValueDemo()
    Debug.Print dateValue("Nov, 23 04")
End Sub

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

Sub Main()
Application.OnTime DateValue("12/31/2007 5:00 pm"), "DisplayAlarm"
End Sub
Sub DisplayAlarm()
    MsgBox "Wake up. It"s time for your afternoon break!"
End Sub