Results 1 to 5 of 5

Thread: Text Box Line Count

  1. #1

    Thread Starter
    Fanatic Member Kings's Avatar
    Join Date
    Aug 2001
    Posts
    673

    Text Box Line Count

    Hey

    How do I count how many lines there are in a RichTexBox

    Thanks
    K i n g s

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    2.  
    3. Private Const EM_GETLINECOUNT = &HBA
    4.  
    5.  
    6. 'To Get How Many Lines In Text Box, in the textbox change event, put
    7.  
    8. Dim lineCount As Long
    9. On Local Error Resume Next
    10. lineCount = SendMessageLong(RichTextBox1.hwnd, EM_GETLINECOUNT, 0&, 0&)
    11. Label1 = Format$(lineCount, "##,###")

  3. #3
    jim mcnamara
    Guest
    [code]
    'VB only way
    function linecount() as long
    Dim a() as string
    a = Split(rtb1.Text,vbcrlf)
    linecount=ubound(a+1)
    end function

  4. #4

    Thread Starter
    Fanatic Member Kings's Avatar
    Join Date
    Aug 2001
    Posts
    673
    Thanks, now I can continue my chat room
    K i n g s

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    what about vbLf's Jim? That will only count Cr's

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