Results 1 to 3 of 3

Thread: How Do I Count The Lines In A RichEdit Control?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Question

    I need to see how many lines are in a RichEdit control in my program. It Delphi i could get it by saying RichEdit1.Lines.Count but don't see anything similar in VB yet. Any suggestions?

    Oh, also how about the character count... Do I just do a Len(RichEdit1.text) ?

    Thanks alot!

    WarrenW

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754

    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const EM_GETLINECOUNT = &HBA
    
    Private Sub Command1_Click()
    Dim lines As Long
    lines = SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, 0)
    End Sub



    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    Guest
    Or you can use the RichTextBox's GetLineFromChar property.

    Code:
    Msgbox RichTextBox1.GetLineFromChar(RichTextBox1.SelStart)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width