在文本框中输入多个.. [英] multiple input in textbox ..

查看:91
本文介绍了在文本框中输入多个..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从单个texbox中获取多个输入...就像在计算器中一样,您必须从单个textbox中获取多个输入,然后您必须处理这些输入..

how to take multiple input from a single texbox ...like in calculator you have to take multiple input from a single textbox and then u have to work on those input..

推荐答案

您需要输入一些内容,将其存储在某个变量中,当用户选择+或-(例如,在calculartor上)时,清除文本框,然后输入下一个值.

然后,您可以对变量进行计算并将结果显示在同一框中.
You need to type something, store it in a variable somewhere, clear the text box when the user chooses + or - (say, on the calculartor), and then enter the next value.

You can then do calculations on the variables and display the result in the same box.


好,这取决于您的要求.
如果要尝试在同一文本框中输入多个条目的事件,则可以使用StringBuilder使用定界符(用户定义)逐步添加值.

因此,您可以通过再次从stringbuilder中剥离单个字符串来进行计算或执行任何操作.

干杯
Balaji
Ok, it depends on your requirement.
If you are going to try an event to go for multiple entries on the same text box, then you may use a StringBuilder to get your values added incrementally with a delimiter (user defined).

So, then you may do your computation or whatsoever, from stripping off the individual strings from the stringbuilder back again.

Cheers
Balaji


您必须在文本框中添加KeyPress事件.可以说,如果用户按下"Enter","+",-","=","Esc"等键,则将选择存储在StringBuilder中的文本n.然后清除文本框.这样,当文本框收到在KeyPress事件中处理的键时,所有输入的字符串都将存储在StringBuilder中.此循环一直进行到您没有任何键停止存储过程为止.

如果按"Esc"键,则循环必须停止,然后使用存储在StringBuilder中的字符串处理所需的任何操作,然后得到结果.
You got to add a KeyPress event on the textbox. Lets say, if user hits "Enter", "+", "-", "=", "Esc", etc keys you pickup the text n store in StringBuilder. Then clear the textbox. This way all string entered will be stored in StringBuilder when the textbox receives a key which is handled in KeyPress event. This cycle goes on untill you hae any key to stop the storing process.

If on "Esc" key the cycle must stop, then process whatever you want with the strings stored in the StringBuilder and you got the results.


这篇关于在文本框中输入多个..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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