运行效果:

VB编程:DateSerial通过闰月判断闰年-47 

程序代码:

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)


相关文章:

  • 2021-11-28
  • 2022-01-01
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-11-28
  • 2021-11-28
  • 2021-09-06
  • 2021-11-28
相关资源
相似解决方案