将ToCharArray方法列入MessageBox或TextBox

时间:2016-05-28 02:58:41

标签: vb.net

我正在尝试使用ToCharArray方法列出用户输入的字符,并在MessageBox或TextBox中向下(垂直)列出这些字符。我希望在TextBox中使用它,但如果它更容易和/或更好,我也会考虑MessageBox。

这就是我目前所拥有的:

Dim P As String = Ques.Text
Dim L As String = P.ToCharArray()
Dim Q As String = LCase(P)
Dim QQ As String = StrReverse(Q)
Dim RP As String = StrReverse(L)
Dim chars() = P.ToCharArray()

If QQ = Q Then
    Ans.Text = "True"

Else
    Ans.Text = "False"

End If
    For index As Integer = 0 To 100
        MessageBox.Show(Ch(index))
Next
Exit Sub

End Sub

1 个答案:

答案 0 :(得分:0)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim x As String  'Holds the Userinput
    x = TextBox1.Text

    Dim VerticalText As String = ""

    For Each item In x.ToCharArray 'For each character in the array append a newLine
        VerticalText += item + vbNewLine
    Next

    TextBox2.Text = VerticalText 'Show the formatted text in another multiline textbox
End Sub