Restrict Label's Caption Length

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Hiren Joshi
    New Member
    • Feb 2008
    • 30

    Restrict Label's Caption Length

    Is it possible to Restrict Label's Caption like up to 4 or 5 characters? e.g. the way we restrict Text Box by Setting MaxLength...

    Regards and Thanks

    Hiren
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    #2
    suppose on lable textchanged event

    you could use

    [code=text]
    dim a as integer = len(label.text)

    if a > 5 then
    error msg
    end if
    [/code]

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by Hiren Joshi
      Is it possible to Restrict Label's Caption like up to 4 or 5 characters? e.g. the way we restrict Text Box by Setting MaxLength...
      Since the label is not editable in the way a textbox is, why would you want to?

      The only way for a value to get there would be if your code put it there, so just don't put in a caption longer than what you want.

      Comment

      Working...