在桌面1.txt中的内容:
*  2005 12 31  0  0  0.00000000                                                 
PG01 -15246.320949  18519.427777 -11153.726375     26.821894                    
PG02  19741.327715 -12513.110413  12184.817005    -24.395785                    
*  2005 12 31  0 15  0.00000000                                                 
PG01 -14911.467205  17109.204322 -13560.588565     26.823994                    
PG02  21064.424892 -12541.591712   9735.216414    -24.395405                    
*  2005 12 31  0 30  0.00000000                                                 
PG01 -14583.297001  15430.116335 -15730.824330     26.825362                    
PG02  22104.609765 -12558.716077   7114.555593    -24.394939                    
其中:*  2005 12 31  0  0  0.00000000     26.821894
*  2005 12 31  0 15  0.00000000   26.823994
*  2005 12 31  0 30  0.00000000   26.825362
是我需要的,请求赐教,帮帮小弟一把!急需,这对我很重要!!

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/4730/4730209.xml?temp=3.327578E-02
      

  2.   

    Open "f:\new.txt" For Input As #1
    Dim b As String
    b = StrConv(InputB(LOF(1), 1), vbUnicode)
    'open 打开文件的路径 for 打开方式(这里是读取,下面的是写入和创建) as 文件号
    Close #1
    '以上为读取文件,以下为写入文件
    Open "f:\new1.txt" For Output As #2
    Print #2, b
    Close #2
    MsgBox "完毕"
    注释: 你把文件复制到我上面二个的地址,就可以看到效果,把你要读取的文件设置为"f:\new.txt"或者自己改一下地址,改为你的文件地址进行读取
    详细参考为http://community.csdn.net/Expert/topic/4730/4730209.xml?temp=.7222864
    你可以对上面的方法进行改造,比如使用STRCONV后,对字符串进行修改,以达到更完美的对文件流的修改,然后写入,以上只是个简单的例子
      

  3.   

    读取这类文件有三种方法:
    1.line input 一行一行的读取
    2.input$(N,#1)   读取N个  
    3.input   一次性读取
      

  4.   

    dim strtmp as stringopen "c:\windows\desktop\1.txt" for input as #1
    text1 = ""
    do until eof(1)
        line input #1, strtmp
        if left(strtmp, 1) = "*" then text1 = text1 & strtmp
    loop
    close #1
      

  5.   

    也可以将你需要的行写入另一个文件:dim strtmp as stringopen "c:\windows\desktop\1.txt" for input as #1
    open "c:\my documents\2.txt" for output as #2
    do until eof(1)
        line input #1, strtmp
        if left(strtmp, 1) = "*" then print #2, strtmp
    loop
    close #2
    close #1