如何从字符串数组中获取值并将它们分配给多行文本框,在其中所有值都用VB.net中的新行分隔

我是神

我用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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档