You can use the following code in the Change event procedure:
If Len(YourTextBox.Text) > YourLimit Then
Call MsgBox("You cannot add any more characters")
YourTextBox.Text = Left(YourTextBox.Text, YourLimit)
End If
If you do something like this, make sure the user knows about the limit and I would add a lable at the top of the text box that I use the Change event procedure to update with the current length of the text box.
I thought that this would work but it does not. On the change event it does look at the field length that was originally there but the length will not change from the originall. for Example: the field may have had the word "test" in it orignally which has a length of 4. Change this to "testy" and the variable that it looks at for the length has not changed (still test) and still has a length of 4. Any ideas?
Yes, note that I used the .Text which does change as the user types into the text box. The .Value or just using the name of the text box will not change until the user exits the text box.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.