[Solved] How to merge two multiline textboxes


There are probably many ways you could do this. I have shown you one below but you would be assuming that textbox two contains the same amount of lines as textbox 1. It doesnt contain any validation but would do what you are asking.

See the comments to understand what is happening.

'Declare empty string for concatinating the text used in textbox 3
    Dim lsText As String = String.Empty
    'Loop for the count of lines in the textbox starting at an index of 0 for pulling data out
    For i As Integer = 0 To TextBox1.Lines.Count - 1
        'Check if lsText has already been assigned a value
        If lsText = String.Empty Then
            'If is has not then you know its the first so dont need a carriage return line feed simply take both values at that index
            lsText = TextBox1.Lines(i) & TextBox2.Lines(i)
        Else
            'Otherwise you want the new value on a new line
            lsText = lsText & vbCrLf & TextBox1.Lines(i) & TextBox2.Lines(i)
        End If
    Next
    'Set the textbox text to the finished concatination
    TextBox3.Text = lsText

0

solved How to merge two multiline textboxes