Search for a word and change it! C#

easy question, I'm a begginer :P

Page 1 of 1

4 Replies - 940 Views - Last Post: 17 July 2009 - 12:43 PM Rate Topic: -----

#1 greatdragon   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 08-November 06

Search for a word and change it! C#

Post icon  Posted 17 July 2009 - 11:39 AM

C#
Search for a word in textBox then change it for a variable
I'm trying to make a program that search for a word in textBox then change it for a variable, in truth my program will help me make php scripts, anyways someone help me please...
I tried to make the code but its hard for me :/
--edit--
I was thinking now if I could use indexOf to search it and replace...

This post has been edited by greatdragon: 17 July 2009 - 11:57 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Search for a word and change it! C#

#2 greatdragon   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 08-November 06

Re: Search for a word and change it! C#

Posted 17 July 2009 - 12:31 PM

private void button6_Click(object sender, EventArgs e)
		{
		   int retorno;
			int car;
		   string php="php";
			char 
		   retorno = textBox6.Text.IndexOf(php);
		   car = php.Length;
		   for (int x = retorno; retorno + car == x; x++)
			  textBox6.Text.CopyTo(retorno, 
		}


I tryed but I can't understand what I got do...

This post has been edited by greatdragon: 17 July 2009 - 12:32 PM

Was This Post Helpful? 0
  • +
  • -

#3 firexware   User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 57
  • Joined: 06-July 09

Re: Search for a word and change it! C#

Posted 17 July 2009 - 12:38 PM

textbox6.Text.Replace should help
Was This Post Helpful? 1
  • +
  • -

#4 Core   User is offline

  • using System.Linq;
  • member icon

Reputation: 784
  • View blog
  • Posts: 5,101
  • Joined: 08-December 08

Re: Search for a word and change it! C#

Posted 17 July 2009 - 12:40 PM

Something like this should do the trick:

string variable = "Replaced String";
textBox1.Text = textBox1.Text.Replace("String To Replace", variable);


Was This Post Helpful? 1
  • +
  • -

#5 greatdragon   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 67
  • Joined: 08-November 06

Re: Search for a word and change it! C#

Posted 17 July 2009 - 12:43 PM

thanks you both guys, I will try to use it :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1