VB编程:IsNumeric判断闰年-48
【摘要】
运行效果:
运行代码:
方法一:
Private Sub Command1_Click() Dim myYear As Boolean If IsNumeric(Text1.Text) Then &n...
运行效果:
运行代码:
方法一:
Private Sub Command1_Click()
Dim myYear As Boolean
If IsNumeric(Text1.Text) Then
If Text1.Text Mod 400 = 0 Then
myYear = True
ElseIf Text1.Text Mod 4 = 0 And Text1.Text Mod 100 <> 0 Then
myYear = True
Else
myYear = False
End If
If myYear = True Then
Picture1.Print Text1.Text & "是闰年!"
Else
Picture1.Print Text1.Text & "是平年!"
End If
Else
Picture1.Print Text1.Text & "不是数字"
End If
End Sub
方法二:
Public Function LeapYear(ByVal yea As Integer) As Boolean '闰年函数
If (yea Mod 4) = 0 Then
LeapYear = (yea Mod 100 > 0) Or (yea Mod 400 = 0)
End If
End Function
学习总结:
通用的步骤,可以使用函数,方便以后调用。
文章来源: pengshiyu.blog.csdn.net,作者:彭世瑜,版权归原作者所有,如需转载,请联系作者。
原文链接:pengshiyu.blog.csdn.net/article/details/81048892
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
作者其他文章
评论(0)