Results 1 to 6 of 6

Thread: In Need of Help

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Location
    Bangalore
    Posts
    25

    In Need of Help

    Is there any method from which I can get the line count in a

    RichTextBox?
    samarthk

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    I'm not sure if this is what you are after.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4. Dim LineCount
    5.  
    6.     On Error GoTo LineErr
    7.     LineCount = Split(RichTextBox1.Text, vbCrLf)
    8.     MsgBox "Line count = " & UBound(LineCount) + 1
    9.    
    10.     Exit Sub
    11. LineErr:
    12.     MsgBox "Line count = 0"
    13. End Sub

  3. #3
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    You can also use API like this:

    VB Code:
    1. 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
    2. Private Const EM_GETLINECOUNT = &HBA
    3. Dim linecount As Integer
    4. '////////////////////////////////////////////////////////
    5.  
    6. linecount = SendMessage(RichTextBox1.hwnd, EM_GETLINECOUNT, 0, 0)
    7. MsgBox linecount
    Baaaaaaaaah

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Faster:

    VB Code:
    1. Private Const EM_GETLINECOUNT = &HBA
    2. 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
    3. Private Sub Command1_Click()
    4. MsgBox SendMessage(Me.RichTextBox1.hwnd, EM_GETLINECOUNT, ByVal CLng(0), ByVal CLng(0))
    5. End Sub


  5. #5
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Damn API again, I have to learn about them someday.

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    oh well,

    win some lose some

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