|
-
Nov 27th, 2003, 03:21 AM
#1
Thread Starter
New Member
Searching for text in a text file
Hi, this will probably be simple for you guys but, I'm trying to search a text file for a last name, and then display the corresponding info underneath the name from the text file such as phone number, address, etc...After it finds it, it then displays it neatly in a windows form. I can't get it to work though..this is what I have so far.
VB Code:
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim input As String 'What I'm searching for
Dim friendFile As System.IO.StreamReader
friendFile = System.IO.File.OpenText("database.txt")
'Use an input box to gain the search string
input = InputBox("Enter the last name of the data you'd like to see.", "Enter Last Name")
'This will only return true if I search for the first name in the text file, but I want it to be able to go down the entire text file
Do
If friendFile.ReadLine = input.ToUpper Then
txtLastName.Text = input.ToUpper
txtFirstName.Text = friendFile.ReadLine()
txtCustNumber.Text = friendFile.ReadLine()
Else : MessageBox.Show("Customer not found.", "Error")
End If
Loop Until friendFile.ReadLine() <> input.ToUpper
End Sub
Last edited by mccullom; Nov 27th, 2003 at 03:49 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|