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.
– Marcelo Macedo
Along those lines
LabelText.Text = "IDCmdpaotj Found!
you are not closing to"
, that wouldn’t be the problem?– Roberto de Campos
as the friend @Robertodecampos passed I believe q the first
IF
are missing the"
.– Doan Casotti
Good afternoon, maybe if you use if inside while or for, solve your problem
– JV M
That’s not it, I typed the wrong code in the question. if is closed in the original code.
– Happy
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?
– jean
By this code I can’t imagine why stop, there’s no command to stop.
– Maniero