Results 1 to 4 of 4

Thread: Textbox Question

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    is it possible to tell how many lines down on a multiline textbox, the text goes? Let me rephrase that if it was confusing, how can i tell how far the text goes down on a textbox? (eg. 3 lines)For example, i am typing this out, and the text has wrapped to make 7 lines. any help?

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    Sure, the following code show you how to count the number of lines in a textbox.

    If you want more information please red my article, Extending the TextBox Control here at VB-World.

    Public Declare Function SendMessage _
    Lib "user32" Alias "SendMessageA" ( _
    ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) As Long
    Public Const EM_GETLINECOUNT = &HBA

    Public Function LineCount(txtBox As TextBox) As Long
    LineCount = SendMessage( _
    TxtBox.hWnd, EM_GETLINECOUNT, 0&, 0&)
    End Function

    Good luck!

    ------------------
    Joacim Andersson
    [email protected]
    [email protected]
    www.YellowBlazer.com



  3. #3

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    Thanks, how would I make it preform a certain task when it has reached, say line 15?

  4. #4
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    Code:
    If LineCount(text1) = 15 then
    'do task
    end if
    Put this in the change event of the textbox or something

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