0

下面是我将数据输入数组并检索信息的代码

输入数据似乎没有问题,但是当我单击按钮检索信息时,它只会在文本框中显示 0。

Public Class Form1

    Dim Array(20) As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim counter As Integer

        For counter = 0 To ListBox1.Items.Count - 1
            Array(counter) = txtEnterMarks.Text(counter)
        Next

        Label1.Text = "omfg"
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        For counter = 0 To Array.Length - 1
            ListBox1.Items.Add(Array(counter))
        Next
    End Sub
End Class
4

1 回答 1

0

再次..尝试这个不同的答案

Structure Student    
    Dim Name As String
    Dim Mark As Integer
End Structure

要将您的输入保存在其中:

Dim StudentsInfo as New List(Of Student)
Dim si As New Student

si.Name = txtEnterName.Text
si.mark = val(txtEnterMark.Text)
StudentsInfo.Add(si)

从 StudentsInfo 中获取价值

txtEnterName.Text = StudentsInfo(0).Name
txtEnterMark.Text = StudentsInfo(0).mark.ToString

关于将其保存到 ListView .. 再次 .. 试试 Google 先生 ...

于 2013-06-23T06:37:34.653 回答