关于我的问题......关于检查文本框! [英] Little problem for me...about checking a textbox!

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

问题描述

我是意大利人......所以......请原谅我的英语。

我有点问题......我能用什么方式查看文本框要知道它是否b / b $ b只包含来自AZ(az),数字(0-9)和下划线( - )以及

点(。)的字符?!?! ?!?


我使用vb.net。


感谢大家。

Hi, i''m italian...so...excuse me for my english.
I''ve a little problem....in what manner i can check a textbox for know if it
contain only character from A-Z (a-z), numbers (0-9), and underscore (-) and
dot (.) ?!?!?!?

I use vb.net.

thank to all.

推荐答案

2005年8月5日


正则表达式允许您轻松检查文本是否包含某些有效(或无效)字符。它位于

System.Text.RegularExpressions命名空间:


Imports System.Text.RegularExpressions


dim有效为boolean = false


dim expression as string =" [A-Za-z / d - 。] {0,}"

''这个exp ^^应检查A-Za-z0-9和 - & 。带有它的角色

允许无限数量的这些角色。然后使用它来检查它是否为
是否为真:


valid = regex.IsMatch(InputString,Expression)''检查是否

inputstring匹配表达式中的规则。 (由于我记忆力差,签名可能会稍微修改

)正则表达式是一个共享类。


如果有效= false则

msgbox(无效输入!!!)

结束如果


正则表达式中的/ d应代表0- 9;有人纠正我

如果我做错了!


你可能会看:

http://msdn.microsoft.com /library/de...sOperators.asp


了解更多信息!希望这会有所帮助并度过美好的一天!


-

Joseph Bittman

微软认证解决方案开发人员


网站: http://71.39.42.23

静态IP


" tranky" < NO **** @ THANKY.YOU>在消息中写道

news:d8 ********************* @ news3.tin.it ...
August 5, 2005

Regular Expressions allow you to easily check whether text contains
certain valid (or invalid) characters. It is located in the
System.Text.RegularExpressions namespace:

Imports System.Text.RegularExpressions

dim valid as boolean = false

dim expression as string = "[A-Za-z/d-.]{0,}"
''This exp ^^ should check for A-Za-z0-9 and the - & . characters with it
allowing unlimited numbers of those chars. Then use this to check whether it
is true or not:

valid = regex.IsMatch(InputString,Expression) '' Checks whether the
inputstring matches the rules in the expression. (the signature might have
to be slightly modified because of my poor memory) Regex is a shared class.

if valid = false then
msgbox("Invalid input!!!")
end if

the /d in the regular expression should stand for 0-9; somebody correct me
if I did this wrong!

You might look at:

http://msdn.microsoft.com/library/de...sOperators.asp

for more info! Hope this helps and have a great day!

--
Joseph Bittman
Microsoft Certified Solution Developer

Web Site: http://71.39.42.23
Static IP


"tranky" <NO****@THANKY.YOU> wrote in message
news:d8*********************@news3.tin.it...
我有一点问题......我可以用什么方式查看文本框,知道是否和点(。)的字符?!?!?!?

我使用vb.net。

感谢所有人。
Hi, i''m italian...so...excuse me for my english.
I''ve a little problem....in what manner i can check a textbox for know if
it
contain only character from A-Z (a-z), numbers (0-9), and underscore (-)
and dot (.) ?!?!?!?

I use vb.net.

thank to all.



|正则表达式中的/ d应该代表0-9;有人纠正我

|如果我做错了!


\ d和\。是不正确的(只是字母,数字和下划线......没有

期间)。


可能值得一提的是在什么情况下放置此代码。您可以根据用户类型或在提供所有输入并且

文本框开始验证后验证
.


简化上述所有内容:


private sub yourTextBoxEvent(_

byval sender as object,_

[args here适当的事件] _

)_

处理你的文本框。[适当的事件])

如果不是typeof sender就是文本框然后返回

dim textBox as textbox = sender

dim exp作为新的正则表达式(" ^ [az \d _] *
| the /d in the regular expression should stand for 0-9; somebody correct me
| if I did this wrong!

\d and \. were incorrect (just letters, numbers, and underscores...no
period).

it may be worth mentioning in what event to place this code. you can either
validate as the user types or after all the input has been provided and the
textbox begins validation.

to simplify the all of the above:

private sub yourTextBoxEvent( _
byval sender as object, _
[args here for appropriate event]_
) _
handles yourTextBox.[appropriate event])
if not typeof sender is textbox then return
dim textBox as textbox = sender
dim exp As new regex("^[a-z\d_]*


",regexoptions .ignorecase)

如果exp.ismatch(textBox.text)然后返回

msgbox(无效输入提供)

end sub


hth,


me
", regexoptions.ignorecase)
if exp.ismatch(textBox.text) then return
msgbox("invalid input supplied")
end sub

hth,

me


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

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