The user pastes a junk of text into a textbox, then he enters specific in another textbox a word like "Good". Then he/she hits a button which does a two things:
- counts the number of "Good" in that string and then displays it in a label like .. "4 TIMES"
- replaces all of them with another word that the user entered
This is what I have so far.
private void button2_Click(object sender, EventArgs e)
{
string Text = TextBox.Text;
Text.Contains("Good");
int position = Text.IndexOf("Good");
int i = 0;
while(position != -1 )
{
MessageBox.Show(position.ToString());
position = Text.IndexOf("Good", position);
i++;
}
lbl.Text = i.ToString();
}