Trying to retrieve the last line from a textbox 
Author Message
 Trying to retrieve the last line from a textbox

You might get some ideas using the code in the text API library at vbnet.
Check out :

How to Select a Text Range Using the API
A method to select text based on its line number in a textbox.

--

Randy Birch, MVP Visual Basic

http://www.*-*-*.com/
http://www.*-*-*.com/

Quote:

>Hi everyone,

>I know this must be so simple, but nevertheless, it has me beat;

>I have a textbox (text1) and I need to retrieve the very last line of text
>(this line could be of variable length) so, I can retrieve this and write
to
>a logfile.
>Has anyone got any good ideas?

>Regards,

>Nduro



Mon, 23 Apr 2001 03:00:00 GMT  
 Trying to retrieve the last line from a textbox
Hi everyone,

I know this must be so simple, but nevertheless, it has me beat;

I have a textbox (text1) and I need to retrieve the very last line of text
(this line could be of variable length) so, I can retrieve this and write to
a logfile.
Has anyone got any good ideas?

Regards,

Nduro



Tue, 24 Apr 2001 03:00:00 GMT  
 Trying to retrieve the last line from a textbox
Hi,

This code do the job.

---xxx---

Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" _
        (ByVal hwnd As Long, ByVal wMsg As Long, _
         ByVal wParam As Long, lParam As Long) As Long

Const EM_GETLINECOUNT = &HBA    'Number of lines
Const EM_LINEINDEX = &HBB       'First char in the current line
Const EM_LINELENGTH = &HC1      'Length of a line

    Dim NumLines As Long
    Dim FirstChar As Long
    Dim numChars As Long
    Dim sLine As String
    Dim curLine As Long

    NumLines = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0, 0&)

    curLine = NumLines - 1

    FirstChar = SendMessage(Text1.hwnd, EM_LINEINDEX, curLine, 0&) + 1

    numChars = SendMessage(Text1.hwnd, EM_LINELENGTH, FirstChar, 0&)

    sLine = Mid$(Text1.Text, FirstChar, numChars)

---xxx---

Nos vemos.
Guillermo
---
Te invito a mis pginas sobre Visual Basic en espa?ol
http://guille.costasol.net/
=====================================================

Quote:

>Hi everyone,

>I know this must be so simple, but nevertheless, it has me beat;

>I have a textbox (text1) and I need to retrieve the very last line of text
>(this line could be of variable length) so, I can retrieve this and write
to
>a logfile.
>Has anyone got any good ideas?

>Regards,

>Nduro



Wed, 25 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trying to retrieve the line in a textbox

2. Trying to retrieve the line in a textbox

3. Textbox/label which add a new line and remove the last line

4. forcing multiline textbox to scroll to last line...

5. delete last line in textbox

6. suppress redraw, always show last line in textbox control

7. Keeping Textbox on last line

8. Retrieving text lines in multiline textbox

9. retrieving txt file contents line by line

10. retrieving txt file contents line by line

11. Read a MultiLine textbox line by line?

12. Limit a multi-line textbox to 10 lines ?

 

 
Powered by phpBB® Forum Software