Hi all
in my application there are many textboxes for amount, percentage etc. how can i limit the user to to enter only numerical values in such textboxes.
Printable View
Hi all
in my application there are many textboxes for amount, percentage etc. how can i limit the user to to enter only numerical values in such textboxes.
input should store in string variable . Then use TRYparse(vb 2005) fucntion to know input is integer or not. This fucntion will convert value to inetegr. if there is not integer then show message. Try :)
This is a very common question. You should search the forum, which you should always do before posting.
Since you are using VS2008 try using a MaskedTextBox control. It should prevent the user from entering non-numerical characters (or any characters not matching the mask).
Quote:
Originally Posted by obi1kenobi
i can not use masked textbox control because it limits the number of digits
Well I don't have a lot of experience with MaskedTextBoxes, so I can't say if that problem can be solved... But I would advise you to consider using NumericUpDown controls since their return type is Decimal (I think).
How about using a NumericUpDown for this? It's not like it was made for this or anything.