Visual Basic 2008 日期和时间函数

(1)Today 日期

(2)TimeOfDay 时间

(3)Now 日期和时间 (yy-mm-dd hh:mm:ss)

例:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

MsgBox("系统日期为:" & Today)
MsgBox("系统时间为:" & TimeOfDay)
MsgBox("系统日期和时间为:" & Now)

End Sub

(4)Year(now) 年

(5)Month(now) 月

(6)Day(日期) 日

(7)Weekday(Now) 星期 (是从星期天开始算的。)

例:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

MsgBox(Year(Now))
MsgBox(Month(Now))
MsgBox(Weekday(Now))

End Sub

(7)Hour(Now) 小时

(8)Minute(Now) 分

(9)Second(Now) 秒

例:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

MsgBox(Hour(Now))
MsgBox(Minute(Now))
MsgBox(Second(Now))

End Sub

你可能感兴趣的:(2008)