I posted my original question after midnight, I was pretty
frazzled by that time. I think I can state the problem
more clearly now.
I have two variable dates. Projectstart and ProjectEnd I
also have two integers projectstart.da y and projectend.day
that correspond to those dates. I want to find out
whether either of two weekend days fall in between them.
Both weekend days have a reacurring integer value based on
the week (5 and 6 because my weekends are actually friday
and saturday) though I am unsure how to refer to them in
code.
I don't have much code now, I deleted my nested if
statements when I realized it was going to be unworkable.
The idea is simple enough though I can recreate it.
Rough code:
Dim intNumberOfDays as integer
Dim intNumberOfWeek days as integer
Dim intNumberOfWeek EndDays as integer
Private Sub MonthCalendar1_ DateChanged(byV al...) Handles
dtmCharges.Date Changed
'Find the number of days the user selected
intNumberOfDays = projectEnd.day - projectStart.da y
btnCalculateVal ue_click (byVal...) Handles
btnCalculateVal ue.Click
'Checking position of the project start day
'Calculate how many weekend versus weekdays based on how
'far away the start day is from the first weekend day
'then checking the total number of days selected to
'determine if it includes weekends
If projectStart.da yOfWeek = 1 and intNumberOfDays = 4 then
intNumberOfWeek Days = 3
intnumberOfWeek EndDDays = 1
else If projectStart.da yOfWeek = 1 and intNumberOfDays = 5
then
intNumberOfWeek Days = 3
intNumberOfWeek EndDays = 3
else if projectStart.da yOfWeek = 1 and intNumberofDays <=3
then
intnumberofWeek days = intNumberOfDays
intnumberofWeek EndDays = 0
else if projectStart.da yOfWeek = 1 and intNumberOfDays >=6
intnumberOfWeek Days = intNumberOfDays - 2
intNumberOfWeek EndDays = 2
end if
end if
end if
end sub
end class
As you can probabaly tell Id basically have to do the same
code checking to see if the projectstart.da y was 1-7
adjusting the numerical values if the day started
Monday,Tuesday, Wednesday,Thurs day,Friday,Satu rday or
Sunday and comparing it to the length of stay.
I hope that makes more sense then my original post.
thank you,
Sand
-----Original Message-----
* "Sand" <an*******@disc ussions.microso ft.com> scripsit: I have a monthCalender that I want users to be able to
select a range of dates (or a single date) then
calculate a value based on the number of days that person has
selected. The values are higher for the weekends so I
need to be able to figure out how many of the selected
days are weekdays versus weekends.
I already have code to tell me the number of days the
person has selected. I also understand how to get the
DayOfWeek. I tried to code an nested if statement that
would check the dayofweek, see how far away from the
weekend it is and then check that against the number of
days the user selected but it has become unwieldly and,
well, pretty crazy looking.
I'm hoping that someone can tell me a simpler coding
method. My other thought was maybe it's possible
something to do with the SelectedRange? I thought maybe
there is a way to loop through selected range to see if
dayofweek for each weekend day fell inside that range
but I really don't know how I would do that (if it's even
possible)especi ally since dayofweek gives an integer
while selectedrange gives dates.
Post code!
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
.