Groups | Blog | Home
all groups > dotnet academic > september 2003 >

dotnet academic : DayofWeek, FirstDayofWeek syntax?


What-a-Tool
9/20/2003 6:46:45 PM
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



Peter van der Goes
9/21/2003 8:37:25 AM

[quoted text, click to view]
FirstDayOfWeek is a property of the MonthCalendar control, not something you
can use with your grid of textboxes. There is also the FirstDayOfWeek
enumeration that specifies the valid values for the DayOfWeek arguments, as
well as the possible return values from VB intrinsic date functions. This
enum (per the help) is designed to be used with the calendar controls to
declare the first day of the week for display purposes.
Unless you write a class definition to define your "custom calendar" and
include a property for the first day of the week and set/get methods to deal
with it, FirstDayOfWeek won't be available unless you use an instance of the
MonthCalendar in your project. Then, it is available only to be used with
the MonthCalendar control.
To make it available in your project outside an existing class, you'd have
to define it.
--
Peter - [MVP - Academic]


What-a-Tool
9/21/2003 6:35:14 PM
Thanks for the reply, but I did find how to do what I needed (or was told
how to, anyway!)

If Row = 0 Then
txtNew.Text = WeekdayName(Col + 1, False, FirstDayOfWeek.Monday)
End If

This method was suggested by a very helpful person on
Microsoft.public.dotnet.languages.vb and is the method that I ended up
using - Worked like a charm!

Thanks - Sean


[quoted text, click to view]

Peter van der Goes
9/21/2003 7:30:13 PM

[quoted text, click to view]
Thanks for showing us that technique, Sean! I never would have thought of
that.

AddThis Social Bookmark Button