Private Sub Command1_Click()
Dim a As Integer, b As Integer
a = Val(Text2.Text)
b = Val(Text1.Text)
c = b Mod 4
Select Case a
Case 2
If c = 0 Then (1)Text3.Text = "29" (2)Else (3)Text3.Text = "28" '这三处应另起一行写
End If
Case 1, 3, 5, 7, 8, 10, 12
Text3.Text = "31"
Case 4, 6, 9, 11
Text3.Text = "30"
Case Else
MsgBox ("没有这个月份")
End Select
End Sub
其实我想 应该是 if行语句和块语句的区别 你先把end if 去掉 试试 应该可以吧 或是把那一点的代码改为 (一行写一句)
If c = 0 Then
Text3.Text = "29"
Else Text3.Text = "28"
End If
是啊 你的那种 写法是if 行语句
不明白您的意思.您仔细看一下,您给的代码里有对应的if啊
case 2
If c = 0 Then Text3.Text = "29"
Else Text3.Text = "28"
End If
C=0旁边不就是ENDIF对应的那个IF吗?
正如endselect对应 select case,endsub对应Private Sub Command1_Click()
if行语句和块语句的区别
if 什么什么 then 什么什么 就不要 end if
if 什么什么 then
什么什么
end if 就要end if
不知道你明白了吗
if 条件 then 语句组 [else 语句组] 是if单行结构,不需要end if结尾