i am able to print all file line in to rich text box but i have a problem to find a specific word from the rich text box.please help me to solve this trouble.
here is my code for taking input from file and print into rich text box

Dim path2 As [String] = "file path"
        
        Dim d As New StreamReader(path2)
        'creating a new StreamReader and passing the filestream object fs as argument
        d.BaseStream.Seek(0, SeekOrigin.Begin)
        'Seek method is used to move the cursor to different positions in a file, in this code, to 
        'the beginning
        While d.Peek() > -1
            'peek method of StreamReader object tells how much more data is left in the file
            RichTextBox1.Text &= d.ReadLine()
            'displaying text from txt file in the RichTextBox
        End While
        d.Close()

Edited 7 Years Ago by ujjval dave: n/a

Please use poll option only when appropriate and do not ask silly question if somebody will help you. (Ofcourse somebody will help if there is somebody who knows what you talking about...)

Hey peter_budo
Thanks For Your Golden advice
next time i'll remember this.
by the way i had developded this code.
after loop just put this code

MsgBox(Val(RichTextBox1.Find(" 127.0.0.1 www.songs.pk", RichTextBoxFinds.MatchCase)))

        RichTextBox1.SelectionFont = New Font("Verdana", 12, FontStyle.Bold)
        RichTextBox1.SelectionColor = Color.Red

You basically want to find a piece of text within another piece of text?

function findit(byRef TheText) as integer
dim i as integer
i=instr(RichTextBox1.text, TheText)
return i
end function

or if you wish to find all occurances something like this will do (I'm a bit rusty with arrays in VB.net):

function findit2(byRef TheText) as integer
dim Results() as integer
dim i as integer =1
dim y as integer =0 
redim Results(0)
While i < len(RichTextBox1.text)
  i=instr(i,RichTextBox1.text, TheText)
  Redim Preserve Results(Ubound(Results)+1)
  Results(y) = i
  y=y+1
  i =i+1
End while
return Results
This question has already been answered. Start a new discussion instead.