vb如何按列读取文本文档数据

按列读入数据后,将第一列的数据赋给一个数组,将第二列的数据赋给另外一个数组?

第1个回答  推荐于2016-05-27
这个你的第一列与第二列之间是空格或者tab隔开的话就简单了
Dim x(10000) as string,y(10000) as string
Open "c:\1.txt"(你的文件路径) for Input as #1
For i=0 to 9999
If Not EOF(1) then
Input #1,x(i),y(i)
Else
Exit For
End If
Close #1

如果是“,”隔开的也可以,但是必须是固定的隔开符号才行,本身很简单,贴一点出来
Dim s(10000) as string,x(10000) as string,y(10000) as string,a() as string
Open "c:\1.txt"(你的文件路径) for Input as #1
For i=0 to 9999
If Not EOF(1) then
Input #1,s(i)
a=Split(s(i),",")
x(i)=a(0)
y(i)=a(1)
Else
Exit For
End If
Close #1
不明白就hi me
or mail to [email protected]本回答被提问者采纳
第2个回答  2010-04-27
文本文档的内容要告诉我啊
相似回答
大家正在搜