Format, .
, :
Public Sub TestDateParsing()
'On my computer, the date format is U.S. (mm/dd/yyyy)'
'This test creates a date string in dd/mm/yyyy format to'
'simulate user input in a different format'
Const TEST_DATE As Date =
Dim inputDate As String
inputDate = Format(TEST_DATE, "dd/mm/yyyy")
'inputDate is "1/6/2009" (June 1 in dd/mm/yyyy format)'
Debug.Print Format(inputDate, "dd/mm/yyyy")
'It`s magic! The above line will print 6/1/2009'
'which is the correct format for my Regional Settings'
End Sub
, . Format .
, , "mm/dd/yyyy" .
"dd/mm/yyyy". Format Format "dd/mm/yyy", , , "mm/dd/yyyy".
, Format , ( "mm/dd/yyyy"), , , "dd/mm/yyyy", . , , : Format . ?;)
, "dd/mm/yyyy", "mm/dd/yyyy".
, , . ( ).
EDIT ( MarkJ) - , Date. , , , .
Public Sub Test()
Dim dte As Date
For dte =
Call TestDateParsing(dte)
Next dte
End Sub
Public Sub TestDateParsing(ByVal dteIn As Date)
'On my computer, the date format is U.S. (mm/dd/yyyy)'
'This test creates a date string in dd/mm/yyyy format to'
'simulate user input in a different format'
Dim sExpected As String
sExpected = Day(dteIn) & " / " & Month(dteIn) & " / " & Year(dteIn)
Dim inputDate As String
Dim dte As Date
inputDate = Format(dteIn, "dd/mm/yyyy")
dte = Format(inputDate, "dd/mm/yyyy")
Debug.Assert sExpected = Day(dte) & " / " & Month(dte) & " / " & Year(dte)
Debug.Print sExpected
End Sub