0
点赞
收藏
分享

微信扫一扫

VB编程:DateSerial通过闰月判断闰年-47_彭世瑜_新浪博客

运行效果: ​VB编程:DateSerial通过闰月判断闰年-47_彭世瑜_新浪博客_html​​


程序代码:

Private Function MonthToLeapYear(ByVal Yea As Integer) As Boolean

   MonthToLeapYear = Day(DateSerial(Yea, 2, 29)) = 29

End Function


Private Sub Command1_Click()

   If Len(Text1.Text) <= 4 Then

       If MonthToLeapYear(Text1.Text) = True Then

           Print Text1.Text & "年是闰年"

       Else

           Print Text1.Text & "年是平年"

       End If

   Else

      Print "错误:请输入正确的年份!"

   End If

End Sub


学习总结:

DateSerial返回包含指定的年、月、日的 Variant (Date)。


语法 DateSerial(year, month, day)

 

举报

相关推荐

0 条评论