我现在有一段TXT数据,如下:
"独山子石化热电厂1号机"
"总数     "
23
"0.定子电压(*)"
5000.00              aaaa           "KV"          100.00         "%"
"1.有功功率(*)"
5000.00             bbbb          "MW"          100.00         "%"
"2.无功功率(*)"
5000.00             cccc          "MVAR"        100.00         "%"
"3.定子电流(*)"
5000.00            dddd          "A"           100.00         "%"
"4.转子电流(*)"
5000.00            eeee           "A"           100.00         "%"
"5.备用"
5000.00           1346.00          "A"           100.00         "%"
"6.备用"
5000.00           1346.00          "A"           100.00         "%"
"7.实际值(*)"
1.00                 1.00          "D"             1.00         "D"
"8.频率设定(*)"
5000.00             50.00          "HZ"           50.00         "HZ"
"9.备用"
2801.00             12.00          "V"            12.00         "V"
"10.备用"
25000.00             50.00          "HZ"           50.00         "HZ"
"11.机端频率(*)"
25000.00             50.00          "HZ"           50.00         "HZ"
"12.触发角度(*)"
25000.00           360.00          "度"           360.00        "度"
"13.备用"
25000.00           360.00          "度"           360.00        "度"
"14.定时中断"
200000.00           20.00          "MS"            20.00        "MS"
"15.阳极电压"
3931.68            410.00          "V"            100.00        "%"
"16.调差系数"
273.88              10.00          "%"             10.00        "%"
"17.计算周期(*)"
1.00                 0.02          "S"              0.02        "S"
"18.采样系数"
1.00                 1.00          " "              1.00        " "
"19.实际角度"
1.00                 1.00          "度"             1.00        "度"
"20.过、欠励退出"
1234                 1.00          " "              1.00        " "
"21.功能投入"
-1.00                1.00          " "              1.00        " "
"22.主、备励切换"
17.00                1.00          " "              1.00        " "
"23.串口查询次数"    100 
"24.串口发出延时"    0.01
"25.串口输入延时"    0.001
"26.串口回读次数"    20 
"A套串口"            1 
"B套串口"            4 我通过以下的代码可以提取:
Open pathstr + "转换系数.txt" For Input As #1
Input #1, title
Input #1, a$
Input #1, jj
For ii = 0 To jj - 1
    Input #1, a
    Input #1, mg_token(ii), rg_token(ii), rg_unit(ii), pg_token(ii), pg_unit(ii)
Next ii
Input #1, fname, delay_nmb
Input #1, fname, delay_out
Input #1, fname, delay_in
Input #1, fname, delay_read
Input #1, fname, acom
Input #1, fname, bcom
Close #1我现在想改变TXT的aaaa\bbbb\cccc\dddd\eeee 的值,变成text1.text....text5.text中的值,其他不变,我试了很多办法,都有问题,请教高手改怎么做,加分!谢谢!

解决方案 »

  1.   


    Open pathstr + "转换系数.txt" For Input As #1 
    Open pathstr + "tmp.txt" For Output As #2Line Input #1, title 
    print #2, titileLine Input #1, a$ 
    print #2, aLine Input #1, jj 
    print #2, jjFor ii = 0 To jj - 1 
        Line Input #1, a 
        Line Input #1, strLine 
        If a = ""0.定子电压(*)"" Then strline = Replace(strLine, "aaaa", Text1)
        If a = ""1.有功功率(*)"" Then strline = Replace(strLine, "bbbb", Text2)
        If a = ""2.无功功率(*)"" Then strline = Replace(strLine, "cccc", Text3)
        If a = ""3.定子电流(*)"" Then strline = Replace(strLine, "dddd", Text4)
        If a = ""4.转子电流(*)"" Then strline = Replace(strLine, "eeee", Text5)    Print #2, a
        Print #2, strLine
    Next ii For ii = 1 To 6
        Line Input #1, strLine
        Print #2, strLine 
    Next iiClose #2
    Close #1
    Kill pathstr + "转换系数.txt"
    Rename pathstr + "tmp.txt", pathstr + "转换系数.txt"
      

  2.   

     If a = ""0.定子电压(*)"" Then strline = Replace(strLine, "aaaa", Text1) 
    语句有问题啊!
      

  3.   

    我原来是通过WRITE 改的,怎么都有问题,求高手提供代码,万分感谢!