TextBox question

  • Thread starter Thread starter Patrick Simonds
  • Start date Start date
P

Patrick Simonds

I need a TextBox which allows for multiple lines of text. Is there any way
to restrict the TextBox to only allow 3 lines of text?
 
Hello Patrick,

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.

Sincerely,
Leith Ros
 
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

NickHK
 

Ask a Question

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.

Ask a Question

Back
Top