Visual Basic如何在找到字符串时跳过一行(行输入)

时间:2014-08-05 13:42:05

标签: vba

如何在找到字符串时跳过一行

 Open Me.FilePath For Input As #lFileNo
    bOpenedCSVFiles = True
    Do Until EOF(lFileNo)

        Line Input #lFileNo, currentStr

如果是Instr(currentStr," Blah")那么 略过这一行并阅读下一行

所以你说这个

Do Until EOF(lFileNo)
    Line Input #lFileNo, currentStr

 If Not InStr(currentStr, "Scenario") Then

'Check the scenario number
    If Me.FieldSeparator.Value = eFieldSeparator.Comma Then
        s = Split(currentStr, ",")
    Else
        s = Split(currentStr, ";")
    End If

    If CDbl(RemoveQuotes(s(LBound(s)))) = Message.ScenarioID Then
        Exit Do
    Else
    End If

End If

1 个答案:

答案 0 :(得分:-1)

查找" Instr" -Function的返回值。当" StringToSearch"没有找到你得到一定的回报值。然后检查这个值并跳过该行,如果" StringToSearch"没找到