Try this function:
Function LastdayInMonth(byVal datDate)
'move to the next month
datDate = dateadd("m",1,datDate)
'move back one day from first day in this month
datDate = dateadd("d",-1,month(datDate) & "/1/" & year(datDate))
'return date as last day in this month
LastdayInMonth= datDate
End Function