none
一維陣列轉二維陣列問題 RRS feed

  • 問題

  • 我想設計一個透過讀檔方式將讀入檔案由一維陣列轉成二維陣列,請問我需要如何做,下列是我的程式碼?

     

     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
                Try
                    Dim reader = My.Computer.FileSystem.OpenTextFieldParser(OpenFileDialog1.FileName, ",")
                    While Not reader.EndOfData
                        Dim dataset() = reader.ReadFields

                                ListBox1.Items.Add(dataset(0) & vbCrLf & dataset(1) & vbCrLf & dataset(2) & vbCrLf & dataset(3))

                     End While
                    MsgBox("匯入成功")
                    reader.Close()
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            End If
        End Sub

    2009年1月7日 下午 03:21

解答

所有回覆