vb.net - How to merge two multiline textboxes -


i need combine 2 multi-line textboxes in vb net, this:
textbox1:
a
b
c
d

textbox2:
1
2
3
4

textbox3:
a1
b2
c3
d4
form 3 textboxes. , button merge/combine/concatenate each value t1 , t2, in t3.

one of attempts:

private sub button3_click(byval sender system.object, byval e system.eventargs) handles button3.click      each line in textbox1.lines         each linex in textbox2.lines             me.textbox3.text += line & linex             me.textbox3.text += environment.newline         next     next  end sub 

but result combination of lines (lines=linex) taken 2 (a1,a2,a3,b1,b2,b3...)

there many ways this. have shown 1 below assuming textbox 2 contains same amount of lines textbox 1. doesnt contain validation asking.

see comments understand happening.

'declare empty string concatinating text used in textbox 3     dim lstext string = string.empty     'loop count of lines in textbox starting @ index of 0 pulling data out     integer = 0 textbox1.lines.count - 1         'check if lstext has been assigned value         if lstext = string.empty             'if has not know first dont need carriage return line feed take both values @ index             lstext = textbox1.lines(i) & textbox2.lines(i)         else             'otherwise want new value on new line             lstext = lstext & vbcrlf & textbox1.lines(i) & textbox2.lines(i)         end if     next     'set textbox text finished concatination     textbox3.text = lstext 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -