VB编程 判断闰年

VB编程 判断闰年,第1张

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

Private Sub Command1_Click()

Dim x%, m%

x = Val(Text1.Text)

Select Case x Mod 4

Case Is <>0

Print "x" &"不是闰年"

Case 0, x Mod 100 <>0

Print "x" &"是闰年"

Case 0, x Mod 100 = 0, x Mod 400 <>0

Print "x" &"不是闰年"

Case 0, x Mod 100 = 0, x Mod 400 = 0

Print "x" &"是闰年"

End Select

End Sub

Dim yea As Integer\x0d\x0aDim LeapYear As Boolean\x0d\x0ayea = InputBox("请输入年号:")\x0d\x0aIf ((yea Mod 4) = 0) Then\x0d\x0aLeapYear = ((yea Mod 100) >0) Or ((yea Mod 400) = 0)\x0d\x0aEnd If\x0d\x0aIf LeapYear Then MsgBox yea &"年是闰年。" Else MsgBox yea &"不是闰年"


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

原文地址: https://outofmemory.cn/yw/8048698.html

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

发表评论

登录后才能评论

评论列表(0条)

保存