Limit numbers in a lable

Hi guys i am sure this one is going to be a easy one for you all,
i am using buttons and enter numbers in to a label and i am want to limit and about of numbers that are allowed in the caption, i am wanting it for date so when they are typing in 15 April 1912, it will only allow then to type in two number in the leading caption and 4 in the last one, these are all different captions
awolarczukAsked:
Who is Participating?
 
jkaiosIT DirectorCommented:
ltlbearand3:
A label control doesn't have the "MaxLength" property, but only TextBox controls.

awolarczuk:
>> i am wanting it for date so when they are typing in 15 April 1912, it will only allow then to type in two number in the leading caption and 4 in the last one

How could you do that in a Label control, which does not directly accept user input, but rather from code as in setting the Caption property?

In the case of using the MaxLength property, try a TextBox control.

For more flexibility in "formatting" the date, use a more sophisticated control such as the DatePicker, which is available in the Microsoft Windows Common Controls 2.0 (MSCOMCT2.OCX).
0
 
ltlbearand3Commented:
Use MaxLength

So you could put label.MaxLength = 2

This would limit it to two characters.
0
 
awolarczukAuthor Commented:
where about do i put the label.maxlength my lable is call day so do i go in the code day.caption = day.caption + 1 and put it in there somewhere
0
 
ltlbearand3Commented:
You can go on the form itself and set the property of MaxLength for each label or in your code when you load the form you can set the property in code for example:

day.MaxLength = 2
year.MaxLength = 4
0
 
ltlbearand3Commented:
jkaios

Sorry,  Yes I was using the term label as had been used by awolarczuk but had assumed Text box control since there was user input.  I should have been more clear.  Thanks for clarifying.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.