在Excel/VBA中检查PC日期区域

在Excel/VBA中检查PC日期区域,vba,excel,Vba,Excel,是否有任何VBA功能允许我检查PC日期格式(区域设置)。这是在控制面板->区域和语言中设置的 Michael几年前我发现了这个,我用它来检查地区日期格式: Function DateFormat() As String DateFormat = CStr(DateSerial(1999, 1, 2)) DateFormat = Replace(DateFormat, "1999", "YYYY") DateFormat = Replace(DateFormat, "99", "YY"

是否有任何VBA功能允许我检查PC日期格式(区域设置)。这是在控制面板->区域和语言中设置的


Michael

几年前我发现了这个,我用它来检查地区日期格式:

Function DateFormat() As String
  DateFormat = CStr(DateSerial(1999, 1, 2))
  DateFormat = Replace(DateFormat, "1999", "YYYY")
  DateFormat = Replace(DateFormat, "99", "YY")
  DateFormat = Replace(DateFormat, "01", "MM")
  DateFormat = Replace(DateFormat, "1", "M")
  DateFormat = Replace(DateFormat, "02", "dd")
  DateFormat = Replace(DateFormat, "2", "d")
  DateFormat = Replace(DateFormat, MonthName(1), "MMMM")
  DateFormat = Replace(DateFormat, MonthName(1, True), "MMM")
End Function
因此,在我的设置中,函数返回:dd/MM/YYYY

您可以在

  • sLongDate
    表示长日期,例如
    dddddd,d。年月日
  • sShortDate
    表示短日期,例如
    yyyy-MM-dd

我可以问一下您真正想要实现什么吗?通常你不需要这些信息。
HKEY_CURRENT_USER\Control Panel\Internationaly\