Click here to Skip to main content
14,694,507 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more: , +
How can i replace a textpassage like: ":)" with a word like "happy".

Here is some code but it doesn't work!

private void txtLog_TextChanged(object sender, EventArgs e)
        {
            string smile1 = ":)";
            if (txtLog.Text == smile1)
            {
                smile1.Replace(":)", "Happy");
            }
        }
Posted

1 solution

umm, hmm ok...

private void txtLog_TextChanged(object sender, EventArgs e)        {            
    string smile1 = ":)";
    if (txtLog.Text.Contains(smile1))
    {
        txtLog.Text = txtLog.Text.Replace(":)", "Happy");
    }
}


Why even ask the question ???:confused::confused::confused:
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900