Results 1 to 10 of 10
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    count letter in textbox.... (2000 sr -1)

    existis a method to count caharcter during the user write in text box and show the remain for...
    Example:
    I have textbox1 and labe1
    1) limit the max insertion of characters for editing in textbox1 in max 256
    2) during the user write in textbox1 show in label1 "max free characrter 256 used xxxx" where xxx is the character used...

    hope undrstand me...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count letter in textbox.... (2000 sr -1)

    Use code like this:
    <code>
    Private Sub TextBox1_Change()
    Me.Label1.Caption = (256 - Len(Me.TextBox1.Text)) & " characters remaining of 256"
    End Sub

    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If Len(Me.TextBox1.Text) >= 256 Then
    KeyAscii = 0
    End If
    End Sub</code>

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count letter in textbox.... (2000 sr -1)

    WORK PERFECT!
    But, when i write all text in tetxbox is in one line, not is possible to format text entered?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count letter in textbox.... (2000 sr -1)

    Set the EnterKeyBehavior and MultiLine properties of the text box to True.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count letter in textbox.... (2000 sr -1)

    excellent, work!

  6. #6
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count letter in textbox.... (2000 sr -1)

    only one on this....
    Is possible to show the in textbox a scrollbar if the text is out of dimnesion....?
    or is only a function for listbox?

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count letter in textbox.... (2000 sr -1)

    Sal,

    In situations like this, you should select the control in the Visual Basic Editor and look at its properties. You'll see that the text box has a ScrollBars property...

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count letter in textbox.... (2000 sr -1)

    sorry i am srtupid.... solved
    I have see the scrollbar show only if i set focus the textbox, and why the cusor go on last character of text in internal to this textbox? is possible to set up the cursor in first character of my text?

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: count letter in textbox.... (2000 sr -1)

    If you set the EnterFieldBehavior property of the text box to 0, the entire text will be selected when you tab into the text box. If you set it to 1, the previously selected text will be highlighted. If you want the insertion point to be at the beginning:

    Private Sub TextBox1_Enter()
    With Me.TextBox1
    .SelStart = 0
    .SelLength = 0
    End With
    End Sub

  10. #10
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: count letter in textbox.... (2000 sr -1)

    Tks for all, explain and code.

Posting Permissions

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