作者sendohmadonn (Chiu)
看板Visual_Basic
标题Re: [.NET] 请问如何将txt档读入二维矩阵里?
时间Sun Sep 19 13:22:21 2010
※ 引述《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
1F:→ OTiux:最后一行的OutPut为何等于一个固定的行呢…? 09/20 08:39