Very new to VBA. I guess MsgBox debugging is the VBA equivalent to print statement debugging in other languages?
If I use Format
to turn a date into a string using dd/mm/yyyy
format, and then print that string with a MsgBox, it instead prints in dd-mm-yyyy
format:
Function MsgBoxFormat()
Const dt As Date = "2022-04-01"
MsgBox (Format(dt, "dd/mm/yyyy"))
End Function
It only seems to do this for the results of the Format
function and only if it uses dd/mm/yyyy
formatting. Other formats and literal strings are not affected:
Function MsgBoxFormat()
Const dt As Date = "2022-04-01"
MsgBox ( _
Format(dt, "dd/mm/yyyy") & vbNewLine & _
Format(dt, "dd-mm-yyyy") & vbNewLine & _
Format(dt, "yyyy-mm-dd") & vbNewLine & _
Format(dt, "dd mmm yyyy") & vbNewLine & _
"01/04/2022" _
)
End Function
I'm a bit worried I've fundamentally misunderstood something about VBA here. Or could this be something obscure relating to my PC's locale settings?
This is VBA 7.1 running on an Access database.