How to continue code after IF

Asked

Viewed 62 times

1

Hello, in a certain part of my program, I need to search for some keywords in a text file. I’m using the IF and CONTAINS method for this, however, when it finds one of these keywords, it stops searching for the next ones, and I need it to research to the end. My code:

Dim sr As New StreamReader(Path)
    Dim rd As String

    rd = sr.ReadToEnd()

    If rd.Contains("IDCmdpaotj") Then
        Str = "IDCmdpaotj  **(Finded!)"
        ListBox1.Items.Add(Str)
        LabelText.Text = "IDCmdpaotj Found!"
        End if

    If rd.Contains("xxpodDooe") Then
        Str = "xxpodDooe  **(Finded!)"
        ListBox1.Items.Add(Str)
        LabelText.Text = "xxpodDooe Found!"
        End if

the problem is that when finding "Idcmdpaotj" it simply stops and does not continue trying to find "xxpodDooe". Someone could help me?

  • Send the whole routine doing a favor Happy.

  • 1

    Along those lines LabelText.Text = "IDCmdpaotj Found! you are not closing to ", that wouldn’t be the problem?

  • as the friend @Robertodecampos passed I believe q the first IF are missing the ".

  • Good afternoon, maybe if you use if inside while or for, solve your problem

  • That’s not it, I typed the wrong code in the question. if is closed in the original code.

  • FINDED? Did you mean FOUND? By the way, the label text will only have the last one found. Are you sure it stops searching? It has a breakpoint?

  • By this code I can’t imagine why stop, there’s no command to stop.

Show 2 more comments

1 answer

0


Solved! The code was inside a timer, and it was being stopped by another. Without this, everything flowed as expected. Thanks for the help!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.