472,146 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

Textbox Numeric only

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.

Nov 20 '05 #1
16 8109
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...
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.

Nov 20 '05 #2
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...
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.

Nov 20 '05 #3
Thats what the validator objects are for silly

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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.

Nov 20 '05 #4
Thats what the validator objects are for silly

"Keith" <an*******@discussions.microsoft.com> wrote in message
news:45**********************************@microsof t.com...
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.

Nov 20 '05 #5
Hi Keith,

Are you only sending messages or are you also reading the answers, you have
asked this question before with not one answer why the answers did not fit.

You have at least 2 good answers on your question in that thread.

Cor
Nov 20 '05 #6
* "=?Utf-8?B?S2VpdGg=?=" <an*******@discussions.microsoft.com> scripsit:
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.


I would allow the user to enter /everything/ he/she wants to enter. In
the textbox's validating event, I would validate input and show an
errorprovider if the input is not valid.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
Hi Herfried,

Please stay in the original thread?

Cor
Nov 20 '05 #8
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Please stay in the original thread?


?!?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9
This started in the thread we have that long discussion in which is now on
2E100

Cor
Nov 20 '05 #10
* "Cor Ligthert" <no**********@planet.nl> scripsit:
This started in the thread we have that long discussion in which is now on
2E100


In my newsreader, that's a new thread ("Textbox Numeric Only").

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #11
Hi Herfried,

I agree with you almost always, but not this time. Simply using the
validation events is fine, but it's inelegant - a user should be guided as
much as possible regarding what they can and can't enter. Besides, there
isn't an app that doesn't use numeric only time and again; why not build the
control to deal with this once, and use it repeatedly?

Bernie

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Ob**************@tk2msftngp13.phx.gbl...
* "=?Utf-8?B?S2VpdGg=?=" <an*******@discussions.microsoft.com> scripsit:
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.


I would allow the user to enter /everything/ he/she wants to enter. In
the textbox's validating event, I would validate input and show an
errorprovider if the input is not valid.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #12
* "Bernie Yaeger" <be*****@cherwellinc.com> scripsit:
I agree with you almost always, but not this time. Simply using the
validation events is fine, but it's inelegant - a user should be guided as
much as possible regarding what they can and can't enter. Besides, there
isn't an app that doesn't use numeric only time and again; why not build the
control to deal with this once, and use it repeatedly?


See:

<URL:http://groups.google.de/groups?selm=2ga8r5Fi77fU1%40uni-berlin.de>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #13
On Fri, 21 May 2004 16:58:51 -0400, Bernie Yaeger wrote:
I agree with you almost always, but not this time. Simply using the
validation events is fine, but it's inelegant - a user should be guided as
much as possible regarding what they can and can't enter. Besides, there
isn't an app that doesn't use numeric only time and again; why not build the
control to deal with this once, and use it repeatedly?


Check out the textbox contron in the VB.Net resource kit. It allow for
these types of things.

It's also free.
--
Chris

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 20 '05 #14
Thank you Bernie. I would very much like to see the code.
Can I download it?

thank you,
Keith

----- Bernie Yaeger wrote: -----

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...
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.

Nov 20 '05 #15
Still disagree - pasting into a textbox doesn't happen 1% as often as simply
keying in.

Bernie

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
* "Bernie Yaeger" <be*****@cherwellinc.com> scripsit:
I agree with you almost always, but not this time. Simply using the
validation events is fine, but it's inelegant - a user should be guided as much as possible regarding what they can and can't enter. Besides, there isn't an app that doesn't use numeric only time and again; why not build the control to deal with this once, and use it repeatedly?


See:

<URL:http://groups.google.de/groups?selm=2ga8r5Fi77fU1%40uni-berlin.de>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #16
* "Bernie Yaeger" <be*****@cherwellinc.com> scripsit:
Still disagree - pasting into a textbox doesn't happen 1% as often as simply
keying in.


For me, it happens often. I am working a lot with scientific software.
For example, I copy a value in international floating point format
("1.234") and paste it into a textbox that expects local format (for
de-DE machines that's "1,234"). If in-place editing doesn't work, I
will have to start Notepad or try to remember the number, or move around
windows to be able to see the number I want to enter.

Another sample is a textbox that expects a setial number consisting of
clocks of numbers/characters separated through "-". If I have a textfile
containing the number separated through " ", then pasting won't work.

There are many other samples, most of them about pasting data that is
not in the same locale as the system, for example, date strings. I
always /hate/ Word's textboxes that pop up when entering a wrong number
("This is not a whole number."). That's really annoying.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #17

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by hennie | last post: by
2 posts views Thread by Patrick De Ridder | last post: by
4 posts views Thread by kidzero | last post: by
1 post views Thread by David Smith | last post: by
reply views Thread by Keith | last post: by
11 posts views Thread by Keith | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.