如何从前端执行添加功能? [英] How can perform add function from front end?
本文介绍了如何从前端执行添加功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我有三个文本框和一个按钮.现在我只在前两个文本框中输入值.现在当我输入按钮时,第三个文本框必须显示我们在前两个文本框中输入的两个值的和.解决方案.
谢谢&Rehards,
Viswanathan.M
Dear,
I have Three text boxes and one button.Now i enter values only in first two text boxes.Now when i enter button,the third text box have to show the sum of two values that we entered in first two text boxes.Kindly give the solution.
Thanks & Rehards,
Viswanathan.M
推荐答案
您需要将两个框中的值解析为适当的数字格式,将它们相加,然后将结果设置到第三个文本框中:
You need to parse the values in the two boxes into appropriate number formats, add them, then set the result into the third textbox:
int x, y;
if (int.TryParse(textBox1.Text , out x) && int.TryParse(textBox2.Text, out y))
{
textboxResult.Text = (x + y).ToString();
}
else
{
MessageBox.Show("Only numbers please!");
}
这篇关于如何从前端执行添加功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文