我的项目包含的内容比我下面的代码中显示的要多得多,但是想知道更好的方法来查看某些数字是否在richtextbox的任何文本行中。我这里只列出3个号码,但还有更多。代码确实有效,但肯定有更好的方法。
For i As Integer = RichTextBox1.Lines.Length - 1 To 0 Step -1
' Get the line
Dim line As String = RichTextBox1.Lines(i)
' Search and find numbers 1, 2, 3 etc.
Dim index As Integer = line.IndexOf("1")
Dim index2 As Integer = line.IndexOf("2")
Dim index3 As Integer = line.IndexOf("3")
' If found the match 1
If index <> -1 Then
' Do code
End If
' If found the match 2
If index2 <> -1 Then
' Do code
End If
' If found the match 3
If index3 <> -1 Then
' Do code
End If
Next