I don't know why this is happening but I have some code that searches a textbox on the form for a string:
Dim strLines() As String = strText.Split(CChar(Environment.NewLine))
Dim i As Integer
Dim strRet As String = ""
For j As Integer = 0 To strLines.Length - 1
i = strLines(j).IndexOf("&&&")
If i >= 0 Then
strRet &= strLines(j).Substring(i + 3) & Environment.NewLine
End If
If strRet.Length > 0 Then
If txtConsole.TextLength > 0 Then
Call ClearCon()
End If
rtxtDefinition.Text = ""
txtWrdDefn.Text = strRet
Dim sourceString As String = New System.Net.WebClient().DownloadString("http://api.urbandictionary.com/v0/define?term=" & strRet)
rtxtDefinition.Text = sourceString
After all this is just processes it and that works fine. The problem is that this gets its info from a game in which you are unable to clear the console, so it keep searching it over and over an keeps returning the same definition. Is there a way to prevent this from happening since the game console cannot be cleared?
As pointed out in my comment, here with code:
Public Class Form1
Dim LastSearchEnd As Integer = 0 'This variable keeps it's value, it's initialized with the value 0 on program start
Private Sub SearchStuff()
Dim strLines() As String = Strings.Split(TextBox1.Text, Environment.NewLine) 'Split the text into lines
For i = LastSearchEnd To strLines.Count - 1 'Start at the value you kept
If strLines(i).Contains("&&&") Then 'Found the value
MsgBox("FOUND IT!!")
LastSearchEnd = i + 1 'We actually keep i+1 because we don't want to search the same line twice
Exit For
End If
Next
End Sub
End Class
That's a broken down example for the thing I think you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.