我使用的是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)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮忙吗?提前致谢
嗯...我找到了更好的方法
'========== 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
Run Code Online (Sandbox Code Playgroud)
但这只适用于excel。