'This uses a streamreader to find a customer's last name in a textfile. Public Function FindCustomer(ByRef name2Find As String, ByRef last As String, ByRef first As String, ByRef tele As String, ByRef fax As String, ByRef foundIt As Boolean) As Boolean '---the parameters in this method MUST be declared ByRef so we can change their values since they were defined in another form. Dim lineFromFile As String 'the data in each line of the file foundIt = False 'declared in the search form Try Using myReader As StreamReader = New StreamReader(customerDataFile) Do Until myReader.EndOfStream lineFromFile = myReader.ReadLine 'read a line If lineFromFile.ToUpper.Trim = name2Find.ToUpper.Trim Then 'match? last = lineFromFile first = myReader.ReadLine tele = myReader.ReadLine fax = myReader.ReadLine foundIt = True Exit Do 'no reason to keep looking End If Loop End Using Catch MessageBox.Show("An error occurred while searching the data file.", msgTitle, _ MessageBoxButtons.OK, MessageBoxIcon.Error) Return False End Try End Function