0

我是 Visual Studio 的新手。我尝试在 Visual Basic 中编写一个简单的程序,该程序从文本框中获取一个 13 位数字并将其数字写入数组。然后它写入数组的第二个成员(第二个数字数字)到另一个文本框,但它不起作用。这是代码:

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim array(12) As Integer
        Dim index As Integer = 11
        Dim code As Long = TextBox1.Text
        Do While index >= 0
            array(index) = code Mod 10
            code /= 10
            index -= 1
        Loop
        TextBox2.Text = array(1)
    End Sub
End Class

你能告诉我有什么问题吗?

4

1 回答 1

1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim array(12) As Integer
    Dim index As Integer = 11
    Dim code As Char() = TextBox1.Text.ToCharArray()

    For i As Integer = 0 To code.Count - 1
        array(i) = Integer.Parse(code(i))
    Next

    TextBox2.Text = array(1)
End Sub
于 2013-03-08T09:43:16.943 回答