我的巨大嵌套条件如下:
Function getArrayOpt(ByVal cb1, ByVal cb2)
If boolAS1 = True And boolAS2 = True Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb1, cb2, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0), st(1))
End If
ElseIf boolAS1 = True And boolAS2 = False Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb1, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0))
End If
ElseIf boolAS1 = False And boolAS2 = True Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb2, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0), st(1))
End If
Else
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb1)
Else
getArrayOpt = Array(cb2, st(0), st(1))
End If
End If
End Function
问题是,我不知道为什么它会抛出预期结束"。我在代码中到处查找,尝试了一堆东西,但仍然不断抛出相同的错误。
答案 0 :(得分:0)
我要在这里自杀,我会在一段时间内复出。问题是第一个嵌套,如果有一个其他不对的话:
Function getArrayOpt(ByVal cb1, ByVal cb2)
If boolAS1 = True And boolAS2 = True Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
这将是"否则如果mon2 =" S"然后"在原始代码中,但权利是" ElseIf":
ElseIf mon2 = "S" Then
getArrayOpt = Array(cb1, cb2, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0), st(1))
End If
ElseIf boolAS1 = True And boolAS2 = False Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb1, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0))
End If
ElseIf boolAS1 = False And boolAS2 = True Then
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb2, vbNullString)
Else
getArrayOpt = Array(cb1, cb2, st(0), st(1))
End If
Else
If mon1 = "D" Then
getArrayOpt = Array(cb1, cb2)
Else If mon2 = "S" Then
getArrayOpt = Array(cb1)
Else
getArrayOpt = Array(cb2, st(0), st(1))
End If
End If
End Function