请高手帮忙?? 一个一个用VB判断平年闰年的函数
来源:百度知道 编辑:UC知道 时间:2024/05/26 02:52:33
Private Sub Command1_Click()
Dim leapYear As Integer
leapYear = Text2.Text
If Text2.Text <> "" Then
If (leapYear Mod 4 = 0 And leapYear Mod 100 <> 0) Or (leapYear Mod 400 = 0) Then
Text1.Text = "this is leap year!"
Else
Text1.Text = "this is not a leapYear"
ElseIf Text2.Text = "" Then
MesBox ("请输入年份")
End If
End Sub
这段程序是哪里错了?提示我没有IF
Dim leapYear As Integer
leapYear = Text2.Text
If Text2.Text <> "" Then
If (leapYear Mod 4 = 0 And leapYear Mod 100 <> 0) Or (leapYear Mod 400 = 0) Then
Text1.Text = "this is leap year!"
Else
Text1.Text = "this is not a leapYear"
ElseIf Text2.Text = "" Then
MesBox ("请输入年份")
End If
End Sub
这段程序是哪里错了?提示我没有IF
这样修改就可以了:
Private Sub Command1_Click()
Dim leapYear As Integer
leapYear = Text2.Text
If Text2.Text <> "" Then
If (leapYear Mod 4 = 0 And leapYear Mod 100 <> 0) Or (leapYear Mod 400 = 0) Then
Text1.Text = "this is leap year!"
Else
Text1.Text = "this is not a leapYear"
End If
ElseIf Text2.Text = "" Then
MsgBox ("请输入年份")
End If
End Sub
仅仅在第八行后加了一个 End If
还有,你后边的MesBox ("请输入年份") 应该是 MsgBox ("请输入年份")