0
我在vb3代码中设置了日期为31/12/2200的错误,并跳转出错,告诉格式不像本地机器。vb3:更改为区域日期格式
解决方案是手动设置12/31/2200,但我感兴趣的是让机器的语言环境自动生成。
如何在vb3中更改区域日期?
我在vb3代码中设置了日期为31/12/2200的错误,并跳转出错,告诉格式不像本地机器。vb3:更改为区域日期格式
解决方案是手动设置12/31/2200,但我感兴趣的是让机器的语言环境自动生成。
如何在vb3中更改区域日期?
我不能帮你用VB3。我现在很多年都没有见过。我可以给你一些能在VB5/VB6中工作的东西。我不知道它会转移到VB3有多好。希望如果它需要工作,你可以将它翻译成VB3或找到可以的人。你会想添加适当的错误处理。
Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Const LOCALE_USER_DEFAULT = &H400
Private Const LOCALE_SSHORTDATE = &H1F ' short date format string
Private Const LOCALE_SLONGDATE = &H20 ' long date format string
Private Sub Form_Load()
Dim strMsg As String
strMsg = "Short Date Format: " & FormatShortDate(DateTime.Now)
strMsg = strMsg & vbCrLf & "Long Date Format: " & FormatLongDate(DateTime.Now)
MsgBox strMsg
End Sub
Private Function FormatShortDate(ByVal vDate As Date) As String
Dim strShortDateFormat As String
Dim lngRet As Long
Dim strReturn As String
'Get short date format
strShortDateFormat = Space(255)
lngRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, strShortDateFormat, Len(strShortDateFormat))
strShortDateFormat = Left(strShortDateFormat, lngRet - 1)
strReturn = Format$(vDate, strShortDateFormat)
FormatShortDate = strReturn
End Function
Private Function FormatLongDate(ByVal vDate As Date) As String
Dim strLongDateFormat As String
Dim lngRet As Long
Dim strReturn As String
'Get long date format
strLongDateFormat = Space(255)
lngRet = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLONGDATE, strLongDateFormat, Len(strLongDateFormat))
strLongDateFormat = Left(strLongDateFormat, lngRet - 1)
strReturn = Format$(vDate, strLongDateFormat)
FormatLongDate = strReturn
End Function
我VB3的回忆是,作为一个16位应用程序开发工具,它本身不是语言环境感知,和你一般能不是像@jac这样完成Windows api调用来执行这些语言环境操作。 – MarkL
变量=“31/12/2000”应为“2000年12月31日” – David