By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Textbox Numeric only

P: n/a
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
Share this Question
Share on Google+
16 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
* "=?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

P: n/a
Hi Herfried,

Please stay in the original thread?

Cor
Nov 20 '05 #8

P: n/a
* "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

P: n/a
This started in the thread we have that long discussion in which is now on
2E100

Cor
Nov 20 '05 #10

P: n/a
* "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

P: n/a
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

P: n/a
* "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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
* "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.