954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Loop not working

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();
                
            }
yousafc#
Junior Poster in Training
82 posts since Feb 2011
Reputation Points: 10
Solved Threads: 1
 

try this

for (int i = 0; i <= 5; i++)
 {
   textBox1.Text = i.ToString();
   textBox2.Text = TextBox1.Text;
 }
Fenrir()
Newbie Poster
20 posts since Jan 2011
Reputation Points: 18
Solved Threads: 5
 

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

Mitja Bonca
Nearly a Posting Maven
2,485 posts since May 2009
Reputation Points: 641
Solved Threads: 474
 

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

yousafc#
Junior Poster in Training
82 posts since Feb 2011
Reputation Points: 10
Solved Threads: 1
 

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

Shilpakmthn
Newbie Poster
11 posts since Jun 2010
Reputation Points: 10
Solved Threads: 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
        }
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: