Sub LeapYear(Year As Int) As Boolean
If Year Mod 4 <> 0 Then Return False
If Year Mod 400 = 0 Then Return True
If Year Mod 100 = 0 Then Return False
Return True
End Sub
Sub DaysOfMonth(Year As Int, Month As Int) As Int
Select Month
Case 2
If LeapYear(Year) Then Return 29 Else Return 28
Case 4, 6, 9, 11
Return 30
Case Else
Return 31
End Select
End Sub
year = 2012
month = 3
'objDateTime is Door Object
objDateTime.New1(False)
objDateTime.CreateNew("System.DateTime" & objDateTime.System_Mscorlib)
daysinmonth = objDateTime.RunMethod3("DaysInMonth",year,"System.Int32",month,"System.Int32")
Msgbox(daysinmonth)
Thank you for All but my function is work too but I did not remember I changed the dateformat.
So this works too:
DateFormat("yyyy.mm.dd.")
maxDayInMonth=DateDay(DateAdd(DateParse(DateYear(Now)&"."&month&".01."), 0, +1, -1))
I think you are doing what I was going to suggest, which was to add one to the current month (remembering to go from 12 to 1); go to 1st day of that month; subtract one day; get day number.
Mike.