VB编程:IsNumeric判断闰年

简介: VB编程:IsNumeric判断闰年

运行效果:

f2f156d16e03873f4778a9cad933ed6f.png




运行代码:


方法一:


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


学习总结:


通用的步骤,可以使用函数,方便以后调用。


相关文章
|
1月前
|
存储 C++
在C++语言中判断是否能被3整除
在C++语言中判断是否能被3整除
57 0
|
1天前
|
C语言
C语言:判断闰年(简单)
C语言:判断闰年(简单)
|
10天前
判断闰年的两种常见方法
判断闰年的两种常见方法
12 1
|
1月前
|
存储 C语言
C语言判断闰年
C语言判断闰年
49 0
|
4月前
|
C语言
C语言第三十九弹--判断闰年and打印1000-2000之间闰年
C语言第三十九弹--判断闰年and打印1000-2000之间闰年
|
6月前
|
C语言
C 语言实例 - 判断闰年
用户输入年份,判断该年份是否为闰年。
38 2
|
10月前
|
Java
Java实现判断闰年
Java实现判断闰年
83 0
|
11月前
|
C语言
【C语言】判断闰年的函数
【C语言】判断闰年的函数
|
C语言
C语言 打印1000年到2000年之间的闰年
闰年的定义: 能被4整除,但不能被100整除的是闰年 能被400整除是闰年
|
Python
python判断年份是否为闰年
python判断年份是否为闰年
88 0
python判断年份是否为闰年