How to search string/word/text on a text file

ryoka012

Active member
Joined
Oct 13, 2011
Messages
32
Programming Experience
Beginner
Hi experts,


Can anyone guide me on how can i search a text using richtextbox from a text file(Note pad).

I'am lost on how can i manage to do this.

Below is my current code.

VB.NET:
Dim S As Integer = [COLOR=#333333]ArrayValue[/COLOR].SelectionStart
        Dim ArrayValue() As String = [COLOR=#333333]ArrayValue[/COLOR].Split(" ") [FONT=Verdana]// this is where my search string is[/FONT]
[FONT=Verdana]                                                                                                      //How can i change it to search in a text file [/FONT]
        For i As Integer = 0 To ArrayValue.Length - 1
            Dim str As String = ArrayValue(i)
            Dim start As Integer = S - str.Length - 1
            If (start >= 0) Then
                If ([COLOR=#333333]RichTextBox1[/COLOR].Text.Substring(start, str.Length).Equals(str)) Then
                     [COLOR=#333333]RichTextBox1[/COLOR].SelectionStart = start 
                     [COLOR=#333333]RichTextBox1[/COLOR].SelectionLength = str.Length
                     [COLOR=#333333]RichTextBox1[/COLOR].SelectionColor = Color.Black
                     [COLOR=#333333]RichTextBox1[/COLOR].SelectionStart = S
                     [COLOR=#333333]RichTextBox1[/COLOR].SelectionLength = 0
                End If
            End If
        Next
         [COLOR=#333333]RichTextBox1[/COLOR].SelectionColor = Color.Red
 
Top Bottom