Jump to content

Incrementar texto ao escrever numa textbox


IvanSerrano
 Share

Recommended Posts

Não é bem isso...

Vou explicar melhor:

      void incriptacao()

        {

            string a = "&$DFD";

            string b = "&%RFF";

            if (textBox1.Text == "a")

            {

                textBox2.Text = a;

            }

            if (textBox1.Text == "b")

            {

                textBox2.Text = b;

            }

Ou seja, se eu escrever na texbox 1 o seguinte texto AB nao fica assim &$DFD&%RFF

Eu queria escrever o que quisesse e adicionasse o valor incriptado percebem?

Por ex:

string i = "&$DFD";

string v = "&$DFG";

string a = "&$DFHH";

string n = "&$DFF";

eu escrevia na textbox Ivan e ficava assim na textboxfinal &$DFD&$DFG&$DFHH&$DFF

Cumprimentos

Link to comment
Share on other sites

if (textBox1.Text == "a")
{
     textBox2.Text += a;           
}     
       
if (textBox1.Text == "b")            
{               
     textBox2.Text += b;            
}

A informática chegou para resolver problemas que antes não existiam

Quem ri por último é porque está conectado a 52 Kbs.

Link to comment
Share on other sites

        int index = 0;

        string a = "&$DFD";

        string b = "&%RFF";

        private void textBox1_TextChanged(object sender, EventArgs e)

        {

            int index1 = textBox1.Text.Length;

            if (index1 >= index)

            {

                string s = textBox1.Text.Substring(index, 1);

                if (s == "a")

                    textBox2.Text += a;

                if (s == "b")

                    textBox2.Text += b;

                index = index1;

            }

        }

Link to comment
Share on other sites

Boas!

Acho que não precisas de tanto trabalho, pelo que percebi da tua dúvida, isto deve bastar:

private void buttonjuntartexto_Click(object sender, EventArgs e)
        {
            labeltextojunto.Text = textBox1.Text + textBox2.Text;
        }

Isto é: Ao carregar no botão, o texto que foi inserido na Textbox1.text mais o Textbox2.text vai aparecer junto labeltextojunto (é o nome que dei a label), não precisas de converter nada, pois por defeito as Textbox do C# já são do tipo string.

Espero ter ajudado! 🙂

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.