Re: [.NET] 請問如何將txt檔讀入二維矩陣裡?
※ 引述《sendohmadonn (Chiu)》之銘言:
: 請輸入專案類型(網站專案或者應用程式專案):應用程式專案
: 請教各位高手, 小弟有一個資料量頗大的txt檔, 欄位數固定, 但是列數不定, 例如下例
: 2001/1/2,上午 08:46:00,4702,4719,4700,4703,77
: 2001/1/2,上午 08:47:00,4718,4729,4715,4723,23
: 2001/1/2,上午 08:48:00,4744,4744,4729,4730,26
: 2001/1/2,上午 08:49:00,4738,4740,4735,4735,22
: 2001/1/2,上午 08:50:00,4733,4733,4729,4729,21
: 2001/1/2,上午 08:51:00,4730,4732,4730,4732,20
: 2001/1/2,上午 08:52:00,4732,4738,4732,4738,23
: 2001/1/2,上午 08:53:00,4737,4740,4737,4738,14
: .... 約一萬筆
感謝大大指點用arrayList方法 給小弟方向...
但是小弟把值取出來時 不管 索引值多少 回傳值都一樣是最後列的資料...
再次麻煩各位大大幫小弟看一下..thx...
程式碼如下:
(宣告)
Public Class TClass
Public f_date, f_time As String
Public f_open, f_high, f_low, f_close, f_value As Integer
End Class
(宣告)
Public chiuClass As New TClass
Public myArrayList As New ArrayList
Private Sub Button1_Click... Handles Button1.Click
Dim sr As New IO.StreamReader("D:\DATA\data.txt")
While Not sr.EndOfStream
Dim Str = sr.ReadLine
Dim tmp = Split(Str, ",")
chiuClass.f_date = tmp(0)
chiuClass.f_time = tmp(1)
chiuClass.f_open = tmp(2)
chiuClass.f_high = tmp(3)
chiuClass.f_low = tmp(4)
chiuClass.f_close = tmp(5)
chiuClass.f_value = tmp(6)
myArrayList.Add(chiuClass)
End While
txtOutput.Text = myArrayList(3).f_open
End Sub
:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.139.145.167
→
09/20 08:39, , 1F
09/20 08:39, 1F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):