Dim shortDateFormat As String Dim lBuffSize As String Dim sBuffer As String Dim lRetGet As Long Dim lRetSet As Long sub form_load()lBuffSize = 256 sBuffer = String$(lBuffSize, vbNullChar) 'get the date information in buffer lRetGet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, sBuffer, lBuffSize) If lRetGet > 0 Then shortDateFormat = Left$(sBuffer, lRetGet - 1) 'this is the existing format of machine End If 'to change the format if doesn't matches ur format 'MM should be used in capital for monyhs,small m are for minutes If LCase(shortDateFormat) <> "yyyy-mm-dd" Then lRetSet = SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, "yyyy-MM-dd")'on sucess lretset have value greater than 0 If lRetSet <= 0 Then MsgBox "日期格式没有变化!", 64, "格式显示"
Dim lBuffSize As String
Dim sBuffer As String
Dim lRetGet As Long
Dim lRetSet As Long
sub form_load()lBuffSize = 256
sBuffer = String$(lBuffSize, vbNullChar)
'get the date information in buffer
lRetGet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, sBuffer, lBuffSize) If lRetGet > 0 Then
shortDateFormat = Left$(sBuffer, lRetGet - 1)
'this is the existing format of machine
End If
'to change the format if doesn't matches ur format
'MM should be used in capital for monyhs,small m are for minutes
If LCase(shortDateFormat) <> "yyyy-mm-dd" Then
lRetSet = SetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, "yyyy-MM-dd")'on sucess lretset have value greater than 0
If lRetSet <= 0 Then
MsgBox "日期格式没有变化!", 64, "格式显示"
End If
End Ifend sub
distinct 针对第一字段的不同值