hi, im a new comer in this forum.
please anyone can help me for find string in large text file (filesize = 1mb to 5 mb)
example: i have a text document file, filename is test.txt
file test.txt contains serial number
The question is what is a code to find that serial number, and if not match will show message box ("Serial number not found") and if found will show message box ("Serial number found")
i also try this code but not working good, because
when i type textbox1.text = 0001
message box show "Serial number found"
i want message box show "Serial number not found" because serial number in test.txt dont have "0001"
this is the code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If FindStringInFile("c:\test.txt", textbox1.text) Then MessageBox.Show("Serial number found") Else MessageBox.Show("Serial number not found") End If End Sub Public Function FindStringInFile(ByVal Filename As String, ByVal SearchString As String) As Boolean Dim Reader As System.IO.StreamReader Reader = New IO.StreamReader(Filename) Dim stringReader As String Try While Reader.Peek <> -1 stringReader = Reader.ReadLine() If InStr(stringReader, SearchString) > 0 Then Return True End While Reader.Close() Return False Catch ex As Exception MessageBox.Show("Exception: " & ex.Message) Return False End Try End Function
maybe all of you guys can help me to write a correct code for what i mean.
thanks for you help and your time.