我用Dim Number() as String
和声明了一个全局字符串数组Dim LineOfText as String
这是我分配字符串数组值的代码
ReDim Number(grdAll.RowCount - 1)
For j As Integer = 0 To grdAll.RowCount - 1
LineOfText = (grdAll.Rows(j).Cells(3).Value.ToString() + ",")
Number = LineOfText.Split(",")
Next
SMS.Show()
然后以另一种形式,在这里我将调用数组的值并将其分配给多行文本框
For j As Integer = 0 To Number.Length - 1
For i As Integer = 0 To Number.Length - 2
txtNumber.Text = Number(i)
Next i
Next
但是我仍然只获得数组的最后一个值,任何人都可以帮助我将数组的值分配给以新行分隔的文本框...
为了提高效率,我强烈建议使用System.Text.StringBuilder:
Dim sbText As New System.Text.StringBuilder(500)
For j As Integer = 0 To Number.Length - 1
For i As Integer = 0 To Number.Length - 2
' This will convert the number to a string, add it to the stringbuilder
' and then append a newline to the text buffer
sbText.AppendLine(Number(i))
Next i
Next
' Now move the buffer into the control
txtNumber.Text = sbText.ToString()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句