2
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by vb2learn
0

You could use this to get a specified line from the TextBox.

TextBox2.Text = TextBox1.Lines(2) '// get line 3.

Or you could loop through all the lines.

For Each txtLine As String In TextBox1.Lines '// loop thru all lines in TextBox.
            If txtLine.StartsWith("leaning daniweb.com") Then '// check if line .StartsWith a specified String.
                TextBox2.Text = txtLine '// get line content.
                Exit For '// exit loop since line was located.
            End If
        Next
0

Hello codeorder

Thanks for this.

But if the line doesn't starts with the word "leaning daniweb.com" then how will i do it.

Like if in textbox1 is written

vb.net
gettext
2 learn leaning daniweb.com
vb2learn

Also, how will i do it if there are multiple lines starting with "leaning daniweb.com"

Eg:

vb.net
gettext
leaning daniweb.com 2 learn
leaning daniweb.com code learn
leaning daniweb.com order learn
vb2learn

And i want to get all the lines starting with leaning daniweb.com

Edited by vb2learn: n/a

0

>>But if the line doesn't starts with the word "leaning daniweb.com" then how will i do it.
Use .Contains("your text") instead of .StartsWith("your text") .

>>Also, how will i do it if there are multiple lines starting with "leaning daniweb.com"
>>And i want to get all the lines starting with leaning daniweb.com
Don't Exit For to exit the loop and add to the .Text in the other TextBox.

TextBox2.Clear() '// clear for new data.
        For Each txtLine As String In TextBox1.Lines '// loop thru all lines in TextBox.
            If txtLine.Contains("leaning daniweb.com") Then '// check if line .Contains a specified String.
                '// If Not empty Then add new line and content, Else just add content.
                If Not TextBox2.Text = "" Then TextBox2.Text &= vbNewLine & txtLine Else TextBox2.Text = txtLine
            End If
        Next
0

Hello
Thanx codeorder once again for the code mate.

Marked As Resolved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.