看板 Visual_Basic 關於我們 聯絡資訊
想請問一下板上的高手 我想要做的是讀取TXT檔 並且把他資料矩陣化 以下是我目前所用的程式碼 但是會發生一個問題 就是使用一維陣列,當讀到下一行時 上一行的資料會被洗掉 我曾想過用二為動態陣列 但是split只允許用一維 那請問一維要怎麼做才能做成二維陣列呢? 我想了好久都想答案 Dim ReadStr() As String Dim i As Integer Dim output As String Dim OpenFileDialog1 As OpenFileDialog = New OpenFileDialog ' Dim IOfile As IO.File OpenFileDialog1.Filter = "純文字檔|*.txt" OpenFileDialog1.FileName = "" OpenFileDialog1.ShowDialog() If OpenFileDialog1.FileName = "" Then MsgBox("使用者取消讀檔", MsgBoxStyle.Exclamation) Exit Sub End If FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input) Do Until EOF(1) ReadStr = Split(LineInput(1), ",") For i = 0 To ReadStr.GetUpperBound(0) output &= i & vbTab & ReadStr(i) & vbCrLf Next Loop MessageBox.Show(output, " ", MessageBoxButtons.OK, MessageBoxIcon.Information) FileClose(1) 先感謝願意協助我的大大了 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.164.33.221