我正在使用excel 2007,ms visual basic 6.0。 我需要检查窗口日期格式(例如,是否使用d / m / yyyy或m / d / yyyy),以便使用以下代码。
Dim lastdateofmonth As Date
Dim lastwhichday As String
slastdayofmonth = "31"
'if the OS system is using m/d/yyyy then use this
lastdateofmonth = (sTxtMMM + "/" + slastdayofmonth + "/" + TxtYYYY)
lastwhichday = Weekday(lastdateofmonth)
'if th OS system is using d/m/yyyy then use this
lastdateofmonth = (slastdayofmonth+ "/" + sTxtMMM + "/" + TxtYYYY)
任何人都可以帮忙吗?提前致谢
答案 0 :(得分:4)
'========== Check OS Date format========
Dim OSDateFormatType As Integer
' 0 = month-day-year; 1 = day-month-year; 2 = year-month-day
If Application.International(xlDateOrder) = 0 Then
OSDateFormatType = 0
ElseIf Application.International(xlDateOrder) = 1 Then
OSDateFormatType = 1
ElseIf Application.International(xlDateOrder) = 2 Then
OSDateFormatType = 2
End If
但这只适用于excel。
答案 1 :(得分:-1)
最好的方法:
if Application.International(xlMDY) then ...
真 - 月,日,年 假 - 日,月,年
https://msdn.microsoft.com/en-us/library/office/ff840213%28v=office.15%29.aspx