|
|
Title | Set the Calendar control's FirstDay property correctly for this computer |
Description | This example shows how to set the Calendar control's FirstDay property correctly for this computer in Visual Basic 6. The program subtracts the current date's weekday number from the current day to get the first date of the week. |
Keywords | WeekDayName, internationalization, first day of the week, locale |
Categories | Software Engineering |
|
|
Thanks to Gary German.
The program uses DateAdd to subtract the current date's day number in days from the current date. This gives the date that is first in the week. It passes Weekday the parameter vbUseSystemDayOfWeek so it numbers the date's weekday number using the system's locale information.
The program then uses Weekday to get the date's day number, again using the parameter vbUseSystemDayOfWeek so it uses the system's locale.
Finally the program sets the Calendar control's FirstDay property to this date's number.
|
|
Private Sub Form_Load()
Dim first_date As Date
Dim first_day_number As Integer
' Get the system's first day of the week.
first_date = DateAdd("d", -(Weekday(Date, _
vbUseSystemDayOfWeek) - 1), Date)
' Convert into a day number.
first_day_number = Weekday(first_date, _
vbUseSystemDayOfWeek)
' Set the calendar's first day of the week number.
Me.Calendar1.FirstDay = first_day_number
End Sub
|
|
|
|
|
|