Results 1 to 4 of 4

Thread: Textbox Rows and Columns

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Toronto, Canada
    Posts
    44

    Post

    Could someone post code for tracking rows and columns in a multiline textbox.

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    To get Line count use this:
    Code:
    Option Explicit
    
    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
    
    Private Const EM_GETLINECOUNT = &HBA
    
    Private Sub Text1_Change()
    	Dim lineCount As Long
    	On Local Error Resume Next
      
    	lineCount = SendMessageLong(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
    	Label1 = Format$(lineCount, "##,###")
    End Sub
    And to get Row Number try to search for this topic on this forum (I asked the same question some time ago but I didn't copy Row Number thing)
    HTH

    Edited by QWERTY on 02-26-2000 at 12:59 PM

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2000
    Location
    Toronto, Canada
    Posts
    44

    Post

    Your code will help, but I need to know where the position of the cursor in the textbox. I can track the position on the cursor by using Keypressed event, but it does trigger when I press the arrow keys. Also if the user moves the cursor with mouse, how do I find the new position of the cusor?

  4. #4
    Addicted Member
    Join Date
    May 1999
    Location
    Californ-I- A
    Posts
    207

    Post

    I long time ago I had achived this using my own functions, which for char position, would counnt the charactors behind the selstart position using a loop, and stop when it gets to chr(10) and chr(13).

    Then for the line count I counted the chr(10) before the current selstart
    Micah Carrick
    Visual Basic 6 SP5
    Visual Basic.NET
    Quixotix Software
    [email protected]
    Download QCM 1.0 - Intelligent ActiveX Control Management

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