Consulting

Results 1 to 3 of 3

Thread: Solved: Limit length of input text box..

  1. #1

    Solved: Limit length of input text box..

    Does anyone know how to do this? I would like to set a hard limit on the number of characters that can be typed into a field.

    With a spreadsheet I can use the length function of the cell - I am thinking of doing this within an event handler - Is this the way to go?

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    I suspect so. (BTW, you know there's a difference between the InputBox Method and the InputBox function?) My first thoughts would be to use a userform with the likes of this:[vba]Private Sub TextBox1_Change()
    MaxLen = 10
    With TextBox1
    If .TextLength > MaxLen Then .Text = Left(.Text, MaxLen)
    End With
    End Sub[/vba]
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3

    What about data validation?

    Hello,
    Have we ruled out data validation: text length? That seems like the simplest method.
    ~Ginger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •