Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are date strings in VB6 relative to machine culture?

I have a legacy VB6 application which 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 label LblStDate display the current date. On my machine, the label ends up displaying something like "27/08/2011" (that is, dd/mm/yyyy). Is it possible that the label would look different on a machine from another culture (for example, displaying "2011/08/27")?

like image 641
user181813 Avatar asked Dec 06 '11 14:12

user181813


People also ask

How do I change the date format in Visual Basic?

Format RequirementsYou must enclose a Date literal within number signs ( # # ). You must specify the date value in the format M/d/yyyy, for example #5/31/1993# , or yyyy-MM-dd, for example #1993-5-31# . You can use slashes when specifying the year first.

How to format string date in c#?

DateTime dateTime16 = DateTime. ParseExact(dateString, new string[] { "MM. dd. yyyy", "MM-dd-yyyy", "MM/dd/yyyy" }, provider, DateTimeStyles.

How to set date format in DateTime c#?

It should be formatted like this: myDateTime. ToString("yyyy/MM/dd hh:mm:ss"); or myDateTime. ToString("yyyy/MM/dd); Because mm is for minute and for month MM should be used.


1 Answers

Yes, VB6 does implicit type conversion, so in your case it is converting a Date type to a String using the user's locale and regional settings. Don't ever rely on a given format being used and once dates/times are converted to a string, you shouldn't really convert them back (unless under controlled circumstances).

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

like image 76
Deanna Avatar answered Nov 01 '22 12:11

Deanna