PDA

View Full Version : Solved: Limit length of input text box..



ChloeRadshaw
06-11-2009, 02:57 PM
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?

p45cal
06-11-2009, 06:17 PM
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:Private Sub TextBox1_Change()
MaxLen = 10
With TextBox1
If .TextLength > MaxLen Then .Text = Left(.Text, MaxLen)
End With
End Sub

Gingertrees
06-12-2009, 06:12 AM
Hello,
Have we ruled out data validation: text length? That seems like the simplest method.
~Ginger