Curiuos error, but still functions

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

Hi,
this is my code
Public Shared Function LastDayOfTheMonth(ByVal dtmdate As Date) As DayOfWeek

Return dtmdate.AddDays(dtmdate.DaysInMonth(dtmdate.Year, dtmdate.Month) -
dtmdate.Day).DayOfWeek()

End Function

on the dtmdate.daysinmonth I get the error

"Access of shared memeber, constant member,..... will not be evaluated"

it wants me to replace dtmdate.daysinmonth with date which would make my
function not correct....

Can anyone give me some clues?
 
Brian said:
Hi,
this is my code
Public Shared Function LastDayOfTheMonth(ByVal dtmdate As Date) As
DayOfWeek

Return dtmdate.AddDays(dtmdate.DaysInMonth(dtmdate.Year, dtmdate.Month) -
dtmdate.Day).DayOfWeek()

End Function

on the dtmdate.daysinmonth I get the error

"Access of shared memeber, constant member,..... will not be evaluated"

it wants me to replace dtmdate.daysinmonth with date which would make my
function not correct....

Can anyone give me some clues?

It is a curious message but what it means is that what your object is has no
relationship to the answer. You can use your date variable but you notice
that the input parameter is what is important.

What it is telling you is that Date.LastDayOfTheMonth is the "correct" way
to call it. It is only a warning.

LS
 
Hi,
this is my code
Public Shared Function LastDayOfTheMonth(ByVal dtmdate As Date) As DayOfWeek

Return dtmdate.AddDays(dtmdate.DaysInMonth(dtmdate.Year, dtmdate.Month) -
dtmdate.Day).DayOfWeek()

End Function

on the dtmdate.daysinmonth I get the error

"Access of shared memeber, constant member,..... will not be evaluated"

it wants me to replace dtmdate.daysinmonth with date which would make my
function not correct....

Can anyone give me some clues?

Why would Date.DaysInMonth(dtmdate.Year, dtmdate.Month) be incorrect?
All of the information for DaysInMonth is supplied in the parameters,
so calling it from an instance is not useful.
 
Jack Jackson said:
Why would Date.DaysInMonth(dtmdate.Year, dtmdate.Month) be incorrect?
All of the information for DaysInMonth is supplied in the parameters,
so calling it from an instance is not useful.

Ok, I see it now.... date.dayinmonth with the parameters passed to it...
 
Back
Top