2025年3月23日 星期日 甲辰(龙)年 月廿二 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > VB

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

时间:05-27来源:作者:点击数:37

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

程序代码:

  • 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)

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门