如何简化添加多个文本输入
我有一个应用程序,其中有大约 100 个文本输入,全部都是数字,
我想简化加法,即。除了说 txt1.text+txt2.text..... 之外的任何其他方式
都会增加我的代码很多
是否有可能 (n+=txt*.text )或类似的事情,
任何帮助都将不胜感激,必须在两天内完成申请,谢谢
i have an application in which i have around 100 textinputs all are numbers
i want to simplify the addition ie. any other way than saying txt1.text+txt2.text.....
that would increase my code a lot
is it possible to have (n+=txt*.text) or some thing like that
any help would be appreciated have to get the application done in two days thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
txt1
、txt2
等是表示this
的类的公共属性,则可以使用以下代码来获取文本输入。要获取连接字符串:
如果文本输入是不同类的属性,请使用对象的实例名称而不是
this
。例如:另一个更干净的解决方案是将它们存储在数组中并循环遍历它们。但这可能需要更改代码的其他部分。
If
txt1
,txt2
etc are public properties of the class representingthis
, you can use the following code to get the sum of the numbers in the text inputs.To get a concatenated string:
If the text inputs are properties of a different class, use the instance name of the object instead of
this
. For example:Another solution that is more clean is to store them in an array and loop through them. But that might require changes in other parts of your code.