vb.net - Splitting Text Box Contents VB2008 -
i splitting contents of 1 text box others in vb, using space split occurs. original text can have different number of spaces know maximum 8, there way vb ignore split commands instead of showing errors?
thanks.
code:
dim stra1 string = trackabox.text dim splita1 string() = stra1.split(" ") a1.text = splita1(0).tostring() a2.text = splita1(1).tostring() a3.text = splita1(2).tostring() a4.text = splita1(3).tostring() a5.text = splita1(4).tostring() a6.text = splita1(5).tostring() a7.text = splita1(6).tostring() a8.text = splita1(7).tostring()
in cases, split 6 , 7 may not required.
prepare array of textboxes, use loop number of items present in splitting result
dim stra1 string = trackabox.text dim splita1 string() = stra1.split(" ") dim ctrltext textbox() = new textbox(){a1, a2, a3, a4, a5, a6, a7,a8} x integer = 0 splita1.length - 1 ctrltext(x).text = splita1(x) next
in way looping on splita1
array used extract string @ current loop position , assign @ corresponding text property of array of textboxes.
consider there no check length of splita1
array because have 8 or less elements , textbox array big enough contain splitted substrings. add check or (as explained in other answer) use split function overload limits resulting array @ 8 elements. split(" ", 8)
Comments
Post a Comment