Syntax of DayofWeek, FirstDayofWeek ?

  • Thread starter Thread starter What-a-Tool
  • Start date Start date
W

What-a-Tool

Have a group of dynamically created text boxes in a calendar like grid. At
the head of each column, the textbox is to contain the day of the week.
Now I am using a Select Case statement to determine the day.
(Yes, this is a homework assignment-it will do fine using the Select Case
statement, but it seems that it would contain less code this alternative
way)

Col & Row are integers.

If Row = 0
Select Case Col
Case 1 = "Monday"
and so on...

What would the syntax of the statements be to set the first day of the week
to Monday using the FirstDayofWeek statement, and then getting a return of
the string day value from the Col number using the DayofWeek statement.
Nothing I've tried seems to work, and I haven't been able to find any code
samples anywhere to help me.
Thanks in advance - Sean
 
What-a-Tool said:
Have a group of dynamically created text boxes in a calendar like
grid. At the head of each column, the textbox is to contain the day
of the week. Now I am using a Select Case statement to determine the
day. (Yes, this is a homework assignment-it will do fine using the
Select Case statement, but it seems that it would contain less code
this alternative way)

Col & Row are integers.

If Row = 0
Select Case Col
Case 1 = "Monday"
and so on...

What would the syntax of the statements be to set the first day of
the week to Monday using the FirstDayofWeek statement, and then
getting a return of the string day value from the Col number using
the DayofWeek statement. Nothing I've tried seems to work, and I
haven't been able to find any code samples anywhere to help me.
Thanks in advance - Sean

I'm not sure if this is what you are looking for:

Microsoft.VisualBasic.DateAndTime.WeekdayName

Call: WeekdayName(1) ... WeekdayName(7) (see docs)
Or: WeekdayName(1, False, FirstDayOfWeek.Monday)
The last parameter is FirstDayOfWeek.System by default. This should work.
Nevertheless, if it doesn't (whyever) explicitly pass the
first-day-of-the-week as the 3rd parameter.

Note: You must _not_ use members of the Enum System.DayOfWeek as the _first_
parameter for WeekdayName.


Concerning DateTime.DayOfWeek: Example: Date.Now.DayOfWeek.ToString =>
"Sunday". Right, today is Sunday. ;-)
 
That was exactly what I wanted - Thank you, thank you, thank you!
This is what I used (to late for my homework, but I still wanted to know!)

'Set Text into column headers(Columns and Rows start with zero)

If Row = 0 Then

txtNew.Text = WeekdayName(Col + 1, False, FirstDayOfWeek.Monday)

End If

Thanks - Sean
 
WeekdayName(1, False, FirstDayOfWeek.Monday)

What's the "false" property set?
Tells it that the default first day of week is not Sunday?
 
What-a-Tool said:
WeekdayName(1, False, FirstDayOfWeek.Monday)

What's the "false" property set?
Tells it that the default first day of week is not Sunday?

Do you use Notepad for programming?
 
No - sorry - stupid of me. Forgot about the "intellisense" feature before I
asked the question. Just copied and pasted your "WeekdayName(1, False,
FirstDayOfWeek.Monday)" into my program, so it didn't come up till I went
back and typed it in manually.
Thanks again
 
Back
Top