Click here to Skip to main content
15,891,766 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have textbox in my form and i want it take only numbers from 1 to 12 only and not any thong else...i am trying but iam not getting the logic for it
Posted
Comments
Nelek 14-Nov-12 16:24pm    
Please don't think we can read minds or do astral projections to see your monitor. If you need help, the least you could do is to explain your problem in such a way, that the users of CP can understand it. Otherwise, nobody will be able to help you.
what have you tried?[^]

1 solution

You say you are trying, but show no evidence of it. You can use Char.IsNumeric and Char.IsControl in the key down event of a textbox to allow only numbers. You can then use int.TryParse to see if the number that you end up with is not in your range, and erase it if it is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900