Results 1 to 6 of 6

Thread: counting lines from a text box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Question

    How do you count the lines from a text box or a richtextbox... ?

  2. #2
    Guest
    Use the EM_GETLINECOUNT message.
    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 iLines As Integer
        iLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0)
        MsgBox ("There are " & iLines & " lines in Text1")
    End Sub
    [Edited by Megatron on 09-08-2000 at 07:10 PM]

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    wow... is that easy or what!!!
    Good lord megatron... how do you know all these stuffs...
    Anywayz thanks alot for the code

  4. #4
    Member
    Join Date
    Sep 2000
    Location
    Virginia
    Posts
    55

    Unhappy Customization?

    This returns the total line count only. What if I want to count only to the cursor? Is there a way to customize for that functionality?
    Thanks,
    Chris

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hope ya still need it! (or actaully I hope you allready have the answer but well...)
    http://www.mvps.org/vbnet/code/texta...urrentline.htm
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6
    Member
    Join Date
    Sep 2000
    Location
    Virginia
    Posts
    55

    Talking THANK YOU!!

    That's it. Nope, I hadn't found an answer yet. Thanks.
    Thanks,
    Chris

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