There really isn't any good way to restrict the number of lines in
multi-line text box. The font size, font style, box size, and case al
effect the wrap around feature which can't be detected in an event lik
pressing the enter key. If there were a window handle to the text bo
this could accomplished using API calls from VBA.
Patrick,
You can use a RichTextBox instead, as it has more properties to play with.
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
With RichTextBox1
If .GetLineFromChar(Len(.Text)) > MaxNumberOfLines-1 Then
MsgBox "That's enough"
KeyCode = 0
End If
End With
End Sub
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.