文本框仅限数字 [英] Textbox Numeric only

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

问题描述

我疯了 - 感到震惊的是文本框控件中没有数字,Alpha和AlphaNumeric属性


我搜索和搜索 - 并找到了其他人的's代码 - 但他们不能完美地工作。有些只允许数字 - 但你不能退格。也许那就是足够好。 - 但肯定有一个只接受数值和退格的文本框并不困难。

Am I crazy - to be shocked that there is no Numeric, Alpha, and AlphaNumeric Property in on the Textbox control

I searched and searched - and found other people''s code - but they don''t work perfectly. Some do only allow numeric - but you cannot backspace. Maybe that is "good enough" - but surely it is not that difficult to have a textbox that only accepts numeric values and backspaces.

推荐答案

嗨Keith,


我开发了一个只有数字的文本框,允许退格。

另外,它提供了leave和keypress事件的扩展

在'调用它的表单中,这样你可以强制一个''0'进入

文本框,如果它留空,以及其他此类活动。我还创建了

一个允许货币 - 因此,2位小数,但没有更多和

小数点后没有任何内容。两个控件也允许减号,但

只作为第一个字符,应该是。


我肯定他们不完美控制,但他们一直很好地工作

对我来说。如果您想查看代码,请告诉我您的需求和

我会尝试提供有用的东西,并告诉我在哪里下载它。

HTH,


Bernie Yaeger


" Keith" <一个******* @ discussions.microsoft.com>在消息中写道

news:45 ********************************** @ microsof t.com ...
Hi Keith,

I''ve developed a textbox that''s numeric only, that allows backspacing also.
In addtion, it provides for extensions to the leave and keypress events
inside the form that''s calling it so that you can force a ''0'' into the
textbox if it is left blank, and other such activities. I''ve also created
one that will allow currency - thus, 2 decimal places, but no more and
nothing after the decimal place. Both controls also allow a minus sign but
only as the first character, as it should be.

I''m sure they''re not perfect controls but they''ve been working very nicely
for me. If you would like to see the code, let me know what you need and
I''ll try to provide something useful, and let me know where to download it.

HTH,

Bernie Yaeger

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
我疯了 - 感到震惊的是文本框控件中没有数字,Alpha和
AlphaNumeric属性?
我搜索和搜索 - 并找到了其他人的代码 - 但他们不是b $ b完美的工作。有些只允许数字 - 但你不能退格。

也许这是足够好的 - 但肯定有一个只接受数值和退格的

文本框并不难。
Am I crazy - to be shocked that there is no Numeric, Alpha, and AlphaNumeric Property in on the Textbox control?
I searched and searched - and found other people''s code - but they don''t work perfectly. Some do only allow numeric - but you cannot backspace.
Maybe that is "good enough" - but surely it is not that difficult to have a
textbox that only accepts numeric values and backspaces.



Hi Keith,


我开发了一个只有数字的文本框,允许退格。

另外,它提供了对假期的扩展和按键事件

在'调用它的表单中,这样你就可以强制一个''0'进入

文本框,如果它留空,等等活动。我还创建了

一个允许货币 - 因此,2位小数,但没有更多和

小数点后没有任何内容。两个控件也允许减号,但

只作为第一个字符,应该是。


我肯定他们不完美控制,但他们一直很好地工作

对我来说。如果您想查看代码,请告诉我您的需求和

我会尝试提供有用的东西,并告诉我在哪里下载它。

HTH,


Bernie Yaeger


" Keith" <一个******* @ discussions.microsoft.com>在消息中写道

news:45 ********************************** @ microsof t.com ...
Hi Keith,

I''ve developed a textbox that''s numeric only, that allows backspacing also.
In addtion, it provides for extensions to the leave and keypress events
inside the form that''s calling it so that you can force a ''0'' into the
textbox if it is left blank, and other such activities. I''ve also created
one that will allow currency - thus, 2 decimal places, but no more and
nothing after the decimal place. Both controls also allow a minus sign but
only as the first character, as it should be.

I''m sure they''re not perfect controls but they''ve been working very nicely
for me. If you would like to see the code, let me know what you need and
I''ll try to provide something useful, and let me know where to download it.

HTH,

Bernie Yaeger

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
我疯了 - 感到震惊的是文本框控件中没有数字,Alpha和
AlphaNumeric属性?
我搜索和搜索 - 并找到了其他人的代码 - 但他们不是b $ b完美的工作。有些只允许数字 - 但你不能退格。

也许这是足够好的 - 但是肯定有一个只接受数值和退格的

文本框并不困难。
Am I crazy - to be shocked that there is no Numeric, Alpha, and AlphaNumeric Property in on the Textbox control?
I searched and searched - and found other people''s code - but they don''t work perfectly. Some do only allow numeric - but you cannot backspace.
Maybe that is "good enough" - but surely it is not that difficult to have a
textbox that only accepts numeric values and backspaces.



那是什么验证器对象是愚蠢的


" Keith" <一个******* @ discussions.microsoft.com>在消息中写道

news:45 ********************************** @ microsof t.com ...
Thats what the validator objects are for silly

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
我疯了 - 感到震惊的是文本框控件中没有数字,Alpha和
AlphaNumeric属性?
我搜索和搜索 - 并找到了其他人的代码 - 但他们不是b $ b完美的工作。有些只允许数字 - 但你不能退格。

也许这是足够好的 - 但肯定有一个只接受数值和退格的

文本框并不困难。
Am I crazy - to be shocked that there is no Numeric, Alpha, and AlphaNumeric Property in on the Textbox control?
I searched and searched - and found other people''s code - but they don''t work perfectly. Some do only allow numeric - but you cannot backspace.
Maybe that is "good enough" - but surely it is not that difficult to have a
textbox that only accepts numeric values and backspaces.



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

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