vb中计算闰年的程序

vb中计算闰年的程序,第1张

dim year as integer 

year=val(inputbox("输入年份"))

if (year mod 4=0 and year mod 100 <>0 ) or year mod 400=0 then 

msgbox "是闰年"

else 

msgbox "不是闰年"

end if

Private Sub Command1_Click()

Dim Y As Long, S As Long, nStr As String

nStr = InputBox("请输入年份:", "输入年份", 2000)

If nStr = "" Then Exit Sub

Y = Val(nStr)

S = DateDiff("d", Y &"-2-1", Y &"-3-1") '获取二月份的天数

If S = 29 Then nStr = "闰年" Else nStr = "不闰年"

MsgBox Y &":" &nStr, vbInformation, "闰年判断"

End Sub

Private Sub Form_Click()

Dim a As Integer

a = Val(InputBox("输入年份"))

If a Mod 400 = 0 Then

Print "是瑞年"

ElseIf a Mod 4 = 0 And a Mod 100 <> 0 Then

Print "是瑞年 "

Else

Print "不是瑞年"

End If

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/8162233.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-14
下一篇2023-04-14

发表评论

登录后才能评论

评论列表(0条)

    保存