Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Information - signs left 1

Status
Not open for further replies.

Mollethewizard

IS-IT--Management
Nov 18, 2002
93
SE
I’ve got a textbox in a user form that are limited in max lenght to 200 signs. I would like to put a label in the form that informs the user form how many signs there are left when he enters text in the textbox. How can I accomplish that?

Christer
 
Hi Christer,

Not entirely sure what you are doing here, but you should be able to do it in the textbox change event ..

Code:
[COLOR=blue]Private Sub TextBox1_Change()
    Me.Label1.Caption = "You have " & 200 - Len(Me.TextBox1) & " signs left"
End Sub[/color]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Hiya Christer

Ifd you're using textboxes on a UserForm you can use the .TextLength property as well. Stick this in the OnChange event of a textbox [tt]txtComments [/tt]to update a label called [tt]lblComments[/tt]:

Code:
Private Sub txtComments_Change()
    If Me.txtComments.TextLength < 200 Then
        Me.lblCommentsLength = "You have " & 200 - Me.txtComments.TextLength & " characters left"
    Else
        Beep
    End If
End Sub

HTH

Cheers
Nikki
[bat] Look, mommy, I'm flying!
 
Thank you all for your swift reply!

Tony asked what I was trying to do – even if you are aware that a textbox only can store 200 characters, how often have you not exceeded that limit whit the result – stop in the middle of the most important sentence in your message!

Therefore I would like the user to know while writing how many characters there are left before he hits the ceiling.

Christer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top