ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox question (https://www.excelbanter.com/excel-programming/366520-textbox-question.html)

Patrick Simonds

TextBox question
 
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?



Leith Ross[_646_]

TextBox question
 

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

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=55918


NickHK

TextBox question
 
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

"Patrick Simonds" wrote in message
...
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?






All times are GMT +1. The time now is 10:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com