Dim x%, y%, ts%
Dim S As String
x = InputBox("年份=")
y = InputBox("月份=")
If (y Mod 4) = 0 And (y Mod 100) <> 0 Then '闰年
If y = 1 Or y = 3 Or y = 5 Or y = 7 Or y = 8 Or y = 10 Or y = 12 Then '月份31天
ts = 31
ElseIf y = 2 Then '闰月
ts = 29
Else '月份30天
ts = 30
End If
S = CStr(x) & "年是闰年"
Else '非闰年
If y = 1 Or y = 3 Or y = 5 Or y = 7 Or y = 8 Or y = 10 Or y = 12 Then '月份31天
ts = 31
ElseIf y = 2 Then '非闰月
ts = 28
Else '月份30天
ts = 30
End If
S = CStr(x) & "年不是闰年"
End If
Print S & "," & CStr(y) & "月天数=" & CStr(ts) & "天"
End Sub
'判断月份时不用再加上对于年的判断了。'窗体放一个text1用于输入年份,一个Command1
Private Sub Command1_Click()
dim a%
a= val(text1text)
if (a Mod 4 = 0 And a Mod 100 <> 0) Or a Mod 400 = 0 then
print "是闰年"
else
print "不是闰年"
end if
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)