您现在的位置是:首页 > 综合范文

告诉你两种判断闰年的简单方法(判断的两个基本特征是什么)

2023-10-26人围观
简介  Option Explicit   Private Sub Command1_Click()   Print 2000   Print IsLeapYearA(2000)   Print IsLeapYearB(2000)   Print 1999   Print IsLeapYearA

  Option Explicit

  Private Sub Command1_Click()

  Print 2000

  Print IsLeapYearA(2000)

  Print IsLeapYearB(2000)

  Print 1999

  Print IsLeapYearA(1999)

  Print IsLeapYearB(1999)

  Print 1998

  Print IsLeapYearA(1998)

  Print IsLeapYearB(1998)

  Print 1997

  Print IsLeapYearA(1997)

  Print IsLeapYearB(1997)

  Print 1996

  Print IsLeapYearA(1996)

  Print IsLeapYearB(1996)

  End Sub

  Function IsLeapYearA(ByVal yr As Integer) As Boolean

  If ((yr Mod 4) = 0) Then IsLeapYearA = ((yr Mod 100) > 0) Or ((yr Mod 400) = 0)

  End If

  End Function

  Public Function IsLeapYearB(ByVal yr As Integer) As Boolean

  IsLeapYearB = Day(DateSerial(yr, 2, 29)) = 29

  End Function

文章评论

    共有条评论来说两句吧...

    用户名:

    验证码:

点击排行

关注微信