I am trying to make a search box for my mini project, the way it's supposed to work is that you type in a certain name and it searches the text file for that word, and if no results are found it displays No results
.
Text File Includes:
Example1 0
Example2 1
Example2 2
Example4 3
Example5 4
I want to be able to search for the name and it show both the name and age found.
In the text box when button is clicked: Example5
<--- (What I'm searching for)
Some pseudocode:
private void DynamicButton_Click(object sender, EventArgs e)
{
Text = this.dynamicTextBox.Text;
// This is how I want it to work:
// search names.txt for Text
// Get the entire line it was found on
if (found) {
MessageBox.Show(result);
}
else
{
MessageBox.Show("No results");
}
}
End result: A MessageBox that says Example5 4