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 y As Integer

If Text1.Text = "" Then

 MsgBox "输入年份"

Else

 y = Val(Text1.Text)

   If (y Mod 4 = 0 And y Mod 100 <>0) Or y Mod 400 = 0 Then

      Text2.Text = Text1.Text &"年是闰年"

   Else

      Text2.Text = Text1.Text &"年不是闰年"

   End If

End If

End Sub

Private Sub Form_Load()

Text1 = ""

Text2 = ""

Command1.Caption = "判断"

End SubEnd Sub

Dim yea As Integer

Dim LeapYear As Boolean

yea = InputBox("请输入年号:")

If ((yea Mod 4) = 0) Then

LeapYear = ((yea Mod 100) >0) Or ((yea Mod 400) = 0)

End If

If LeapYear Then MsgBox yea &"年是闰年。" Else MsgBox yea &"不是闰年"


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存