VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Auto resize a text box depending on the number of lines actually in the box.

by Ricardo Pineda (1 Submission)
Category: String Manipulation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 9th December 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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.



    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


Download this snippet    Add to My Saved Code

Auto resize a text box depending on the number of lines actually in the box. Comments

No comments have been posted about Auto resize a text box depending on the number of lines actually in the box.. Why not be the first to post a comment about Auto resize a text box depending on the number of lines actually in the box..

Post your comment

Subject:
Message:
0/1000 characters