Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 2nd, 2005, 9:28 PM   #1
Bman
Newbie
 
Bman's Avatar
 
Join Date: Nov 2005
Posts: 3
Rep Power: 0 Bman is on a distinguished road
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!
Bman is offline   Reply With Quote
Old Dec 2nd, 2005, 11:08 PM   #2
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
I'm sure you can do it with Regular Expressions which is a great thing to learn anyway. :p

Google is your friend.
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Dec 3rd, 2005, 12:39 AM   #3
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 406
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
Look into double.TryParse()
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Dec 3rd, 2005, 6:00 AM   #4
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
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");
}
}
Pedja is offline   Reply With Quote
Old Dec 4th, 2005, 1:23 PM   #5
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
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
Kilo is offline   Reply With Quote
Old Dec 4th, 2005, 3:07 PM   #6
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
My english is not very good. I don't know what tablature means. Piss poor I get.
What is wrong with the code?
Pedja is offline   Reply With Quote
Old Dec 4th, 2005, 10:32 PM   #7
BlazingWolf
Hobbyist Programmer
 
Join Date: Sep 2004
Posts: 207
Rep Power: 5 BlazingWolf is on a distinguished road
Quote:
Originally Posted by Kilo
wow pedja, first of all that tablature is piss poor. Second please surround all code in tags.
If you don't have anything to add the post and all you want to do is flame someone don't post.

Pedja, just make sure to put your code in "[code]" tages. Without qoutes and the trailing tage with a / before code of course.
__________________
_______________________________
BlazingWolf
BlazingWolf is offline   Reply With Quote
Old Dec 5th, 2005, 5:33 AM   #8
Pedja
Programmer
 
Join Date: Nov 2005
Location: Belgrade, Serbia & Montenegro
Posts: 31
Rep Power: 0 Pedja is on a distinguished road
Send a message via ICQ to Pedja Send a message via MSN to Pedja Send a message via Yahoo to Pedja
Thank you very much!
Pedja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:05 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC