每次单击按钮时如何创建新输出? [英] How do I make new output every time I click a button?

查看:72
本文介绍了每次单击按钮时如何创建新输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个有输入文本框的程序,在输入数字4之后,我在label1中得到4 * 100的结果,现在我做了那个,我得到400作为输出,但我想让它堆叠,所以下次我点击一个按钮我得到800然后1200,1600 ......



我尝试了什么:



private void button1_Click(object sender,EventArgs e)

{

int value;

int number;







if(Int32.TryParse(textBox1.Text,out value)& &(checkBox1.Checked == false))

{

if(number == 4)

{



number = 4 * 100;



label1.Text = number.ToString();



}

}

}

I want to make a program that has textbox for input and after i type in number 4, i get result of 4*100 in label1, now i did that and i get 400 as output, but i want to make it stack, so next time i click a button i get 800 then 1200, 1600...

What I have tried:

private void button1_Click(object sender, EventArgs e)
{
int value;
int number;



if (Int32.TryParse(textBox1.Text, out value) && (checkBox1.Checked == false))
{
if (number == 4)
{

number = 4 * 100;

label1.Text = number.ToString();

}
}
}

推荐答案

Pars e标签值与解析文本框的方式相同,并在将其转换为字符串之前使用该值添加到数字中,然后将其放回标签中。
Parse the label value in the same way you parsed the textbox, and use that value to add to the number before you convert it to a string, and put it back into the label.


这篇关于每次单击按钮时如何创建新输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆