Click here to Skip to main content
13,550,883 members
Rate this:
Please Sign up or sign in to 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 14-Nov-12 9:02am
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180515.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100