View Full Version : Solved: Limit character input in a textbox
jammer6_9
06-12-2010, 06:42 AM
I was looking for the text box properties if i can limit the input to 200 characters only but there was no options? can we do this by giving a code?
Private Sub UserForm_Initialize()
Me.TextBox1.MaxLength = 200
End Sub
Tinbendr
06-12-2010, 07:33 AM
IF you want to give the user a little feedback, then
Private Sub TextBox1_Change()
If TextBox1.TextLength > 10 Then
MsgBox "Too long"
TextBox1.Text = Left(TextBox1.Text, TextBox1.TextLength - 1)
End If
End SubLeave the Maxlength at 0 and let this sub manage it.
jammer6_9
06-13-2010, 12:16 AM
Perfect... Thanks:thumb
Hi there. I get an "object required" error message if I try running that code. Has anyone else had the same issue?
Hi there. I get an "object required" error message if I try running that code. Has anyone else had the same issue?
Hi JJF and welcome to vbax!
I am sure you will be happy you joined, as there are a lot of good folks here who will go out of their way to help you. As I have responded to many (new members) before, there is just the greatest amount of patience and helpfulness here.
Anyways, as to your issue - I would suggest you start your own thread. Certainly include a link to this one for your initial question, but a new thread not only helps you, but others searching later.
Now to your question - what code errors? Presuming the TextBox is named TextBox1, both Tinbendr's code and mine seems to run, so please show us exactly how you wrote the code that fails.
Hope to help,
Mark
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.