Are date strings in VB6 relative to machine culture?

I have an outdated VB6 application that contains this code:

Begin VB.Label LblStDate Alignment = 1 'Right Justify AutoSize = -1 'True [Blah blah blah....] Top = 0 Width = 75 End [...] LblStDate = Date 

This makes the LblStDate label display the current date. On my machine, the label ends with a display of something like "08/27/2011" (i.e. dd / mm / yyyy). Is it possible that the label will look different on a machine from a different culture (for example, displaying "2011/08/27")?

+6
source share
1 answer

Yes, VB6 does implicit type conversion, so in your case it converts the Date type to String using the user's locale and regional settings. Never rely on the format that is used, and as soon as the dates / times are converted to strings, you should not translate them back (unless they are controlled by circumstances).

You can get the same result using an explicit call to CStr(Date) .

+5
source

Source: https://habr.com/ru/post/903198/


All Articles