我现在学习function函数,在标准模块里增加了如下代码 ,用于取得某月的天数,但是取得的天数都是30天,比如说8月应该是31天,但用此方法取得的天数也是30天,2月用此方法取得的天数也是30天,不知道自己错那儿了,请高手指教,谢谢了。
Function tianshu(riqi As Date) As Byte '求某月天数
tianshu = DateSerial(Year(riqi), Month(riqi) + 1, Day(riqi)) - riqi
'dateserial函数用来取得当前日期加1个月份的日期,再减去当前日期就等于该月的天数
End Function
Function tianshu(riqi As Date) As Byte '求某月天数
tianshu = Day(DateSerial(Year(riqi), Month(riqi) + 1, 0))
'dateserial函数用来取得当前日期加1个月份的O天=当前日期的最后一天!再用DAY 取天数
End Function
Function tianshu(riqi As Date) As Byte '求某月天数
tianshu = Day(DateSerial(Year(riqi), Month(riqi) + 1, 0))
'dateserial函数用来取得当前日期加1个月份的O天=当前日期的最后一天!再用DAY 取天数
End Function