如何检查数字并输入文本框 [英] how to check for numeric and enter in text box
问题描述
有没有办法检查文本框中的条目并确保它是
数字?
另外,我可以捕获回车键吗?并将其称为按钮点击事件?
对不起,如果这听起来很愚蠢,但我试图解决.Net中的
差异问题我之前的所有编程都是在VB6中完成的
谢谢
-
Tony
" anthonymelillo" <无************ @ earthlink.net> schrieb有没有办法检查文本框中的条目并确保它是数字?
另外,我可以捕获回车键并制作它叫一个按钮点击事件
?
查看表格的Defaultbutton属性。
对不起,如果这听起来很愚蠢,但我正试图解决这个问题
.Net中的差异因为我以前的所有编程都是在VB6中完成的
我不想在输入时限制用户的输入。尝试使用
目标类型的(共享)Parse函数将
文本框''内容转换为数值。抓住发生的异常以确定转换是否成功。
-
Armin
" anthonymelillo" <无************ @ earthlink.net> scripsit:有没有办法检查文本框中的条目并确保它是
数字?
您可以使用''Double.TryParse''或''IsNumeric''。
此外,我可以捕获回车键并将其调用为按钮点击事件?
创建一个按钮并将其分配给表单''''AcceptButton''属性。
-
Herfried K. Wagner
MVP·VB Classic,VB.NET
< http://www.mvps.org / dotnet>
尝试IdNumeric()函数....
如果IsNumeric那么
做一些很酷的事情
else
messageBox(非酷炫的错误)
结束如果
希望它能帮助
Armin Zingler < AZ ******* @ freenet.de>在消息中写道
news:el ************** @ tk2msftngp13.phx.gbl ..." anthonymelillo" <无************ @ earthlink.net> schrieb有没有办法检查文本框中的条目并确保它是数字?
另外,我可以捕获回车键并制作它调用一个按钮点击事件
?
看看Form的Defaultbutton属性。
对不起,如果这听起来很愚蠢,但我想来因为我以前的所有编程都是在VB6中完成的,所以.Net中的差异很大。
我打算在输入时不限制用户的输入。尝试使用的
目标类型的(共享)Parse函数将
Textbox''内容转换为数值。抓住发生的异常以确定转换是否成功。
-
Armin
Is there any way to check the entry in a text box and make sure it is
numeric ?
Also, can I catch the enter key and make it call a button click event ?
Sorry if this sounds stupid, but I am trying to come to grips with the
differences in .Net since all my prior programming was done in VB6
Thanks
--
Tony
"anthonymelillo" <no************@earthlink.net> schriebIs there any way to check the entry in a text box and make sure it
is numeric ?
Also, can I catch the enter key and make it call a button click event
?
Have a look at the Defaultbutton property of the Form.
Sorry if this sounds stupid, but I am trying to come to grips with
the differences in .Net since all my prior programming was done in
VB6
I prefer not to limit the user''s input when typing. Try to convert the
Textbox'' content to a numeric value using the (shared) Parse function of the
destination type. Catch occuring exceptions to find out if conversion was
successful.
--
Armin
"anthonymelillo" <no************@earthlink.net> scripsit:Is there any way to check the entry in a text box and make sure it is
numeric ?
You can use ''Double.TryParse'' or ''IsNumeric''.
Also, can I catch the enter key and make it call a button click event ?
Create a button and assign it to the form''s ''AcceptButton'' property.
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
try the IdNumeric() function....
if IsNumeric then
do something cool
else
messageBox("So non-cool error")
end if
hope it helps
"Armin Zingler" <az*******@freenet.de> wrote in message
news:el**************@tk2msftngp13.phx.gbl..."anthonymelillo" <no************@earthlink.net> schriebIs there any way to check the entry in a text box and make sure it
is numeric ?
Also, can I catch the enter key and make it call a button click event
?
Have a look at the Defaultbutton property of the Form.Sorry if this sounds stupid, but I am trying to come to grips with
the differences in .Net since all my prior programming was done in
VB6
I prefer not to limit the user''s input when typing. Try to convert the
Textbox'' content to a numeric value using the (shared) Parse function of
the destination type. Catch occuring exceptions to find out if conversion was
successful.
--
Armin
这篇关于如何检查数字并输入文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!