日曆
VBA 支援 2 個日曆: Gregorian 和 Hijri
Calendar
屬性用於修改或顯示當前日曆。
日曆的 2 個值是:
值 | 不變 | 描述 |
---|---|---|
0 |
vbCalGreg | 公曆(預設) |
1 |
vbCalHijri | Hijri 日曆 |
例
Sub CalendarExample()
'Cache the current setting.
Dim Cached As Integer
Cached = Calendar
' Dates in Gregorian Calendar
Calendar = vbCalGreg
Dim Sample As Date
'Create sample date of 2016-07-28
Sample = DateSerial(2016, 7, 28)
Debug.Print "Current Calendar : " & Calendar
Debug.Print "SampleDate = " & Format$(Sample, "yyyy-mm-dd")
' Date in Hijri Calendar
Calendar = vbCalHijri
Debug.Print "Current Calendar : " & Calendar
Debug.Print "SampleDate = " & Format$(Sample, "yyyy-mm-dd")
'Reset VBA to cached value.
Cached = Calendar
End Sub
該 Sub 列印以下內容;
Current Calendar : 0
SampleDate = 2016-07-28
Current Calendar : 1
SampleDate = 1437-10-23