![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2005
Posts: 3
Rep Power: 0
![]() |
Textbox validation
Hi, I’m looking for help on validation, I would like to know how to validate the data entered in a text box. I would like to restrict the box to # and give the user message that they can only enter a number. Can someone show me how this is done or direct me to info on this?
Thanks! ![]() |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
I'm sure you can do it with Regular Expressions which is a great thing to learn anyway. :p
Google is your friend.
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
#3 |
|
Professional Programmer
|
Look into double.TryParse()
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#4 |
|
Programmer
|
I guess it should go something like this:
TextBox1.KeyPress+=new KeyPressEventHandler(Validate); private void Validate(object sender,System.Windows.Forms.KeyPressEventArgs e) { if(!Char.IsNumber(e.KeyChar)) { e.Handled=true;//this way you prevent the letter to be written in the Text box MessageBox.Show("Write something"); } } |
|
|
|
|
|
#5 |
|
Expert Programmer
|
wow pedja, first of all that tablature is piss poor. Second please surround all code in tags.
__________________
"When in Rome, Do as the Romans Do" "Beauty is in the eye of the BEER holder" "Save your breath your going to need it for your blow up doll later" SearchLores.org |
|
|
|
|
|
#6 |
|
Programmer
|
My english is not very good. I don't know what tablature means. Piss poor I get.
What is wrong with the code? |
|
|
|
|
|
#7 | |
|
Hobbyist Programmer
Join Date: Sep 2004
Posts: 207
Rep Power: 5
![]() |
Quote:
Pedja, just make sure to put your code in "[code]" tages. Without qoutes and the trailing tage with a / before code of course.
__________________
_______________________________ BlazingWolf |
|
|
|
|
|
|
#8 |
|
Programmer
|
Thank you very much!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|