Solved

line number

Posted on 2007-03-30
2
167 Views
Last Modified: 2010-04-23
How can I return the line number of a multiline text box?
0
Comment
Question by:thenrich
2 Comments
 
LVL 3

Expert Comment

by:paix120
ID: 18826587
Well, I've never tried this, but here are a few ideas:

I've heard you can try to write a function to cound the number of ASCII return characters chr(10) before the current cursor position in a rich text box.

Or, if your textbox is going to remain a fixed size (i.e. not resize with the window), you could use a fixed-width font and figure out how many characters fit on a line, and divide the number of characters before the cursor by the characters per line.

EDIT: I just looked and found this code that should help

http://www.freevbcode.com/ShowCode.Asp?ID=2493
0
 
LVL 28

Accepted Solution

by:
iboutchkine earned 250 total points
ID: 18835648
this will return the current line number

<System.Runtime.InteropServices.DllImport("user32")> Shared Function _
    SendMessage(ByVal hWnd As Integer, ByVal wMsg As Integer, _
    ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function

' Determine the current line in a multiline TextBox control
' Example: MessageBox.Show(GetTextBoxCurrentLine(TextBox1))

Function GetTextBoxCurrentLine(ByVal tb As TextBox) As Integer
    Const EM_LINEFROMCHAR As Integer = &HC9
    Return SendMessage(tb.Handle.ToInt32(), EM_LINEFROMCHAR, -1, 0) + 1
End Function
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net - Project Software to help the Developer 7 40
Creating a route in asp.net webforms 2 32
RLDC Reporting in Visual studio 11 30
vb.net 1 month apart 11 35
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question