• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

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
0
awolarczuk
Asked:
awolarczuk
  • 3
2 Solutions
 
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
 
jkaiosCommented:
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:
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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now