文本框值 [英] textbox values

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

问题描述

大家好,

在我的表单中,我有一个文本框,在该文本框中,我将传递诸如A1 A2 A3 A4之类的值,如果再次传递A1或上述任何一个值,它应该提醒我,我该怎么办

hi all,

in my form i have text box, in that textbox i ll pass value like A1 A2 A3 A4, If again pass A1 or any of the abouve value its should alert me, how shall i do it

推荐答案

您可以通过以下操作进行检查:
(此示例在c#中,但是您应该明白了)
You can check by doing something like:
(This example is in c#, but you should get the point)
if (!TextBox1.Text.Contains(value_to_be_inserted))
{ 
TextBox1.Text += value_to_be_inserted;
}



但是请注意,这假定要添加的字符串将不是文本框中已经包含的字符串的部分字符串.要进行检查,您可能需要使用分隔符:空格,逗号等,根据您的数据有效.或者,如果需要,您可以将每个字符串存储到列表中,然后进行检查.



Beware though, this assumes that strings to be added will not be partial strings of strings already contained in the text box. To check for that, you will probably need to use a delimiter: white space, comma, etc, whatever works according to your data. Or if needed, you could store each string as you add them into a list and check against that.


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

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