vb为什么老说else没有if
来源:百度知道 编辑:UC知道 时间:2024/05/15 17:48:53
If Index = 0 Then Text1.Text = ""
ElseIf signfleg = True Then
Select Case c
Case 1
Text1.Text = a + b
Case 2
Text1.Text = a - b
Case 3
Text1.Text = a * b
Case 4
Text1.Text = a / b
End Select
End if
If 条件1 Then
语句1
ElseIf 条件2 Then
语句2
End If
上述是If块结构得标准写法。
Private Sub Command2_Click(Index As Integer)
If Index = 0 Then
Text1.Text = ""
ElseIf signfleg = True Then
Select Case c
Case 1
Text1.Text = a + b
Case 2
Text1.Text = a - b
Case 3
Text1.Text = a * b
Case 4
Text1.Text = a / b
End Select
End If
End Sub
If Index = 0 Then Text1.Text = "" --- 这是完整的单行IF结构
ElseIf signfleg = True Then --- 此处的ElseIf当然缺少IF了
修改成
If Index = 0 Then
Text1.Text = ""
ElseIf signfleg = True Then
If Index = 0 Then Text1.Text = ""
ElseIf signfleg = True Then
'错误
If Index = 0 Then
Text1.Text = ""