I have two text box

Textbox1and Textbox2 and button1
textbox1.text = 1;
textbox2.text = 0;

Now I want when I click on button1.textbox2's data increment. this is my code

for (int i = 0; i <= 5; i++)
            {
                textBox2.Text = textBox1.Text[i].ToString();
                
            }

try this

for (int i = 0; i <= 5; i++)
 {
   textBox1.Text = i.ToString();
   textBox2.Text = TextBox1.Text;
 }

On each button click you would like to increment it by 5?
Or what is that for loop there?

I am Retrieving Studentid from sql and show in textbox1.its Show right.but I want if textbox1's text is 10000data show of textbox1 after increment 1.
as a 10001.
Example
Textbox1 Loop Texbox2
10000 +1 10001

u should do it like this,on button click event.
int i=convert.toint32(tex1.text);
text2.text=i+1;

Are you looking for something like this?

private void button1_Click(object sender, EventArgs e)
        {
            // augment txbox1 value and put in txbox2
            int id =int.Parse(this.textBox1.Text);
            ++id;
            this.textBox2.Text = id.ToString();
            // if txbox1 contains 10001, txbox2 will now contain 10002
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.