Link to home
Start Free TrialLog in
Avatar of kkclub23
kkclub23

asked on

Assign a particular line of text in a multi line text box to a string variable

How can I assign a particular line of text in a multi line text box to a string variable?

Say for example the text box Text1 contains these text:

This is the first line
This is the second line
This is the third line

I would like to assign the text on the third line (i.e."This is the third line") to a variable

It is best that the function does not utilise vbCrLf or carriage return.

Hopefully the function can have the form :
Getline( Text1.Text,2) where Text1.Text is the text inside the textbox and 2 is the content of line 2 i.e. "This is the second line".

So to extract the second line to a variable, the code will be something like:

Variable1=Getline(Text1.Text,2)

Thanks a million for the help!
Avatar of falconew
falconew

kkclub23,
Why not to check the VBCRLF? I think it is the only way to getting the line you want.
http://www.vb-world.net/php-bin/printfriendly.php?articlepageid=74

Is an API solution that shows you how to achieve this.
You will also need to include the api declaration for sendmessage:

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_GETLINE = &HC4
Avatar of Anthony Perkins
Please maintain your open questions:

Questions Asked 11
Last 10 Grades Given A A A A B  
Question Grading Record 5 Answers Graded / 5 Answers Received

Thanks,
Anthony
ASKER CERTIFIED SOLUTION
Avatar of RichW
RichW
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial