vb中if elseif语句不向下执行

来源:百度知道 编辑:UC知道 时间:2024/05/03 07:47:26
If nnn <> 0 Then
stry = Mid(a(X1 + 1), 1, nnn - 1)
strb = Mid(a(X1 + 1), nnn + 1, n1 - nnn)
nnn = 0
End If

'---------------查找-------------------------------
If InStr(stry, "18") <> 0 Then

wy18(t) = "18"

ElseIf InStr(stry, "17") <> 0 Then

wy17(t) = "17"
ElseIf InStr(stry, "15") <> 0 Then

wy15(t) = "15"
ElseIf InStr(stry, "89") <> 0 Then

If nnn <> 0 Then
stry = Mid(a(X1 + 1), 1, nnn - 1)
strb = Mid(a(X1 + 1), nnn + 1, n1 - nnn)
nnn = 0
End If
'---------------查找-------------------------------
If InStr(stry, "18") <> 0 Then
wy18(t) = "18"
ElseIf InStr(stry, "17") <> 0 Then
wy17(t) = "17"
ElseIf InStr(stry, "15") <> 0 Then
wy15(t) = "15"
ElseIf InStr(stry, "89") <> 0 Then
wy89(t) = "89"
ElseIf InStr(stry, "13") <> 0 Then
wy13(t) = "13"
End If
'stry = Mid(a(X1 + 1), 1, nnn - 1)执行后,stry的值是唯一的
当查找到stry=18或17,15,89,13后或都没有查找到,就跳到ENDIF后面去了

简单的方法:将每种情况的条件语句分开写。也就是
if 条件 then
。。。。
end if
if 条件 then
。。。。
end if



这样 不容易出错。条例也比较清晰。

ELSE IF 应该只会执行其中一条语句..或者全部不执行.. 不可能执行两条的

只执行一个ELSE IF 后,就会转向E