1,345676.98,345678,456
2,456788,33,345677,213
3,345628,45,345678,378
相当于是 电号,X,Y,Z,我想选种每一行的 X,代码应该怎么写啊

解决方案 »

  1.   

    '定义结构
    private type test
    n1 as integer
    n2 as float
    n3 as integer
    n4 as integer
    end type
    '读文件
    dim s as string
    dim str as test
    open s for input as #1
    do while not eof(1)
     line #1,s
     f1(s,str)    '函数
    loop
    close #1
    '自定义分
    割函数
      

  2.   

    他没有给你分割函数
    你的每一行的数据的宽度都是固定的吗?
    另外那个结构体,可以全部都是integer,不用float
    dim a as test
    a.n1=mid(s,3,6)
    其他类似
      

  3.   

    也可以不用结构体,如果每一行数据个数都相同,可以这样写:    Dim Str1 As String
        Dim Str2 As String
        Dim Str3 As String
        Dim Str4 As String
        Dim Str5 As String
        Dim sn As Integer    sn = FreeFile
        Open txtFileName For Input As #sn  'txtFileName是文本文件名
        Do Until EOF(sn)
            Input #sn, Str1, Str2, Str3, Str4, Str5
            '此处添加你对Str2处理的代码
        Loop
        Close #sn