dim textline as string
dim txtarray() as string
dim s() as string
dim g() as string
dim i as integer
i=0
open "D:\zuobiao.txt" for input as #1
do while not eof(1)
    line input #1 ,textline
    redim preserve txtarray(i) as string
    txtarray(i) = textline
    redim preserve s(i) as string
    if i>=50 and i <=100 then
        s(i-50)=txtarray(i)
        g()=split(s(i-50),"    ",3)
    end if 
    i=i+1
loop
close #1
redim f(50,2) as double
for i =0 to 50
    f(i,0)=cdbl(g(0))
    f(i,1)=cdbl(g(1))
    f(i,2)=cdbl(g(2))
next
end sub
以上程序实现的是将符合条件的zuobiao.txt(此文件中是一些空间点的三维坐标,一个点一行)中的行赋值给s()数组,然后又需要将s()中的每一列作为一个数值向量进行赋值,上述程序仅仅是把s()中的数按列赋值给f()。
在实际的运行结果中出现了问题,还请大侠们帮忙!!

解决方案 »

  1.   

    g()=split(s(i-50)," ",3) '仅仅包含了一行的数据后面得到的结果肯定都是一样的。
        Dim g(50, 2) As String
        Do While Not EOF(1)
          Line Input #1, textline
          ReDim Preserve txtarray(i) As String
          txtarray(i) = textline
          ReDim Preserve s(i) As String
          If i >= 50 And i <= 100 Then
            s(i - 50) = txtarray(i)
            For j = 0 To 2
              g(i - 50, j) = Split(s(i - 50), " ", 3)(j)
            Next
          End If
          i = i + 1
        LoopLZ这代码的效率太差
      

  2.   


    就像你说的一样,确实是后面得到的结果是一样的。我很久以前学的vb,现在在解决问题的时候用上了,又重新学的,能达到目的就行了,根本没有效率可言。
    谢谢你的指点,我的qq:51451112,希望以后可以多向你学习~
      

  3.   

    谢谢你,已经采用了king06的意见。