Click here to Skip to main content
14,693,622 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hai ,
how to search a particular words in text file using vb.net
Posted

Read a chunk of the text file, for instance a line, into a String object and then use the String.IndexOf method.
   
Comments
Amir Mahfoozi 2-Feb-12 5:45am
   
+5
Use this code to find specific word in text file

Dim InputStr As String = TextBox1.Text

        For Each FileStr As String In IO.Directory.GetFiles("C:\your folder", "*.txt")

            If IO.File.ReadAllText(FileStr).IndexOf(InputStr) >= 0 Then

                ListBox1.Items.Add(IO.Path.GetFileName(FileStr))

            End If

        Next


Thanks
SP
   
Comments
byank 18-Jul-12 8:34am
   
How to write this in visual c++?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900