Ben
Ben

Reputation: 69

VB.Net Split A Group Of Text

I am looking to split up multiple lines of text to single them out, for example:

 Url/Host:ftp://server.com/1
 Login:Admin1 
 Password:Password1

 Url/Host:ftp://server.com/2
 Login:Admin2 
 Password:Password2

 Url/Host:ftp://server.com/3
 Login:Admin3 
 Password:Password3

How can I split each section into a different textbox, so that section one would be put into TextBox1.Text on its own:

 Url/Host:ftp://server.com/1
 Login:Admin1 
 Password:Password1

Upvotes: 0

Views: 500

Answers (1)

Hans Olsson
Hans Olsson

Reputation: 55059

If that's the exact format you could just split it on two newlines in a row:

Dim text As String ' your text
Dim sep() As String = {vbNewLine & vbNewLine}
Dim sections() As String = text.Split(sep, StringSplitOptions.None)

and then just loop through them and put one value in each Textbox.

Upvotes: 1

Related Questions