在文本框中显示所有数组内容

时间:2016-08-07 14:00:25

标签: arrays vb.net winforms

所以我尝试将项添加到数组中,然后在文本框中返回数组中的所有项。有人能告诉我我做错了什么吗?当我点击按钮时,它出错或我得到router.post('/new-job', upload, function(req, res, next) { var newJob = { // ... 或者它没有显示所有项目,只显示一个完整或部分项目。 edit1:这是更新的代码。

system.string[]

1 个答案:

答案 0 :(得分:0)

如果您的Do Until字符串中有任何与“A”和“B”不同的字母,则strletters阻止将无限期地继续。务必始终增加x值:

Do Until x = TextBox1.TextLength
    ' Some conditions
    ' Some more conditions        
    x = x + 1 ' Increment regardless
Loop

此外,您可以使用strholder轻松连接String.Join数组的输出:

TextBox2.Text = String.Join(String.Empty, strholder)

更新

这是一个包含其他几种方法的代码片段......

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ' Converting a string to a char array
        Dim charArray() As Char = TextBox1.Text.ToCharArray
        ' Converting a string to a string array
        Dim stringArray() As String = TextBox1.Text.Select(Function(c) c.ToString).ToArray

        ' Concatenate using a For Each loop
        For Each ch In charArray ' or stringArray
            ' do something with each ch...
            TextBox2.Text &= ch ' Concatenate using the & operator
            'TextBox2.Text += ch ' Concatenate using the + operator
        Next

        ' Converting a char array back to a string
        TextBox2.Text = String.Join(String.Empty, charArray)
        ' Converting a string array back to a string, method 1
        TextBox2.Text = String.Join(String.Empty, stringArray)
        ' Converting a string array back to a string, method 2
        TextBox2.Text = stringArray.Aggregate(Function(final, sCh) final & sCh)

        ' In your case you could just simply...
        TextBox2.Text = TextBox1.Text.Replace("A"c, "346,").Replace("B"c, "917,")
    End Sub
End Class

至于选择连接运算符,您可以查看this