Talk2Tom11
Well-known member
I am running into a little problem. I am having my program look for a txt file based on info that is put in from the user. The problem is I cant find a way to give an error msgbox if the file is not found. My code is below.
Code:
Dim sr As IO.StreamReader = IO.File.OpenText(txtBoxLast.Text + txtBoxFirst.Text + ".TXT")
Dim Found As Boolean = False
Do While (sr.Peek() <> -1) And (Not Found)
Last = sr.ReadLine
First = sr.ReadLine
Gender = sr.ReadLine
Age = sr.ReadLine
room = sr.ReadLine
id = sr.ReadLine
extension = sr.ReadLine
guests = sr.ReadToEnd
If txtBoxLast.Text = Last Then
txtBoxGender.Text = Gender
txtBoxAge.Text = Age
txtBoxRoom.Text = room
txtBoxID.Text = id
txtBoxextension.Text = extension
txtBoxGuest.Text = guests
Found = True
End If
Loop
sr.Close()
If Not Found Then
message = ("Name Not Found. Be sure to check the spelling")
MsgBox(message, , "Information Not Found")
End If