2017-01-20 5 views
0

날짜를 31/12/2200으로 설정 한 vb3 코드에서 오류가 발생하여 형식을 알리는 오류가 로케일 시스템과 유사하지 않습니다.vb3 : 로케일 날짜 형식으로 변경

해결책은 수동으로 12/31/2200으로 설정하는 것입니다. 그러나 내가 관심을 갖는 것은 기계의 로케일을 자동으로 가져 오는 것입니다.

어떻게 vb3에서 로케일로 변경할 수 있습니까?

+0

변수 = "31/12/2000"는해야한다 "12/31/2000" – David

답변

1

나는 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 
+1

VB3의 내 기억은 16 비트 응용 프로그램 개발 도구로, 그 자체가 아니었다 인식 로케일, 당신은 일반적으로 할 수 있다는 것입니다 이러한 로켈 작업을 수행하기 위해 @jac이 여기에서 수행 한 것처럼 Windows API 호출을 수행하지 마십시오. – MarkL