Auto resize a text box depending on the number of lines actually in the box.
Auto resize a text box depending on the number of lines actually in the box.
API Declarations
Public Const EM_GETLINECOUNT = &HBA
Rate Auto resize a text box depending on the number of lines actually in the box.
(2(2 Vote))
Dim Sum As Long
Dim NewHg As Long
Dim lngLineCount As Long
On Error Resume Next
With cTextBox
'get the number of lines in the edit control
lngLineCount = SendMessageLong(.hwnd, EM_GETLINECOUNT, 0&, 0&)
lngLineCount = lngLineCount + 1
Sum = 255
NewHg = lngLineCount * (Sum)
If lngLineCount >= 2 Then
NewHg = NewHg - (lngLineCount * 54)
End If
.Height = NewHg
.SelStart = 0
.SelStart = Len(cTextBox)
End With
End Sub
Private Sub Text1_Change()
AutoResize Text1
End Sub
Auto resize a text box depending on the number of lines actually in the box. Comments
No comments yet — be the first to post one!
Post a Comment