Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
MessageBox.Show(StripLines("this is line 1 <br/> this is line 2 <br/> this is line 3 <br/> this is line 4 <br/> this is line 5 <br/>", 3))
MessageBox.Show(StripLines("this is line 1 <br/> this is line 2 <br/> this is line 3 <br/> this is line 4 <br/> this is line 5 <br/>", 10))
MessageBox.Show(StripLines("this is line 1 <br/> this is line 2 <br/> this is line 3 <br/> this is line 4 <br/> this is line 5 <br/>", 0))
MessageBox.Show(StripLines("this is line 1 <br/> this is line 2 <br/> this is line 3 <br/> this is line 4 <br/> this is line 5 <br/>", -1))
MessageBox.Show(StripLines("this is line 1 <br/> this is line 2 <br/> this is line 3 <br/> this is line 4 <br/> this is line 5 <br/>", 2))
End Sub
[COLOR=red][b]
Private Function StripLines(ByVal stringHtmlArg As String, ByVal NumberOfLinesRequired As Integer) As String
Dim separator As String = "<br/>"
Dim stringHTML As String = String.Empty
Dim htmlLines() As String
Try
htmlLines = stringHtmlArg.Split(separator, NumberOfLinesRequired + 1, StringSplitOptions.RemoveEmptyEntries)
stringHTML = String.Join(separator, htmlLines, 0, NumberOfLinesRequired)
Catch ex As ArgumentOutOfRangeException
' INFO: Value of NumberOfLinesRequired is out of range. Do nothing.
End Try
Return (stringHTML)
End Function
[/b][/color]