标题:VB里怎么把TXT文件内容提取后需要的后重新输出成文件?
取消只看楼主
xiao986211
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-5-9
结帖率:0
已结贴  问题点数:20 回复次数:1 
VB里怎么把TXT文件内容提取后需要的后重新输出成文件?
如把下面的数据提取
W
Z 50.52
Z-14.
Z-14.5
Z-15.
Z50.52
T3.7
UD12_R-R0.08-0.00*12.0*0.08*120.00
W
Z 50.52
Z-8.753
Z-9.053
Z-9.352
Z-9.651
Z-9.95
Z50.52
T4.9
UD6_R-R0.08-0.00*6.0*0.08*120.00
W
Z 50.52
Z-4.955
Z-5.005
Z-5.051
Z-5.097
Z-5.143
Z-5.189
Z50.52
T5.5
UD4_R0.2-R0.08-0.00*4.0*0.20*120.00
W
Z 50.52
Z-14.5
Z-15.
Z-14.5
Z50.52
T7.4
UD12_F-R0.08-0.00*12.0*0.50*120.00
W
Z 50.52
Z-10.035
Z-9.535
Z-10.035
Z-9.535
Z-10.035
Z-9.535
Z50.52
T7.7
UR1.5_T-0.00*3.0*1.50*65.00

需要成下面的内容,z 在每段落只需要最小的值,
Z-15.
T3.7
UD12_R-R0.08-0.00*12.0*0.08*120.00
Z-9.95
T4.9
UD6_R-R0.08-0.00*6.0*0.08*120.00
Z-5.189
T5.5
UD4_R0.2-R0.08-0.00*4.0*0.20*120.00
Z-14.5
T7.4
UD12_F-R0.08-0.00*12.0*0.50*120.00
Z-9.535
T7.7
UR1.5_T-0.00*3.0*1.50*65.00
2015-05-09 21:58
xiao986211
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2015-5-9
得分:0 
我的思路是先把文件按 W 分成每段再存几个文件,然后在提取整理。但是每次提取的都是一样的,
帮我看看那有问题呀。。。。。
 

Dim bit7 As String '将文本全部读入
Dim str7() As String  '分割行    分割符为“回车键”
Dim cz
Dim cc
Dim bit11 As String '将文本全部读入
Dim str11() As String  '分割行    分割符为“回车键”
Dim bit12 As String '将文本全部读入
Dim str12() As String  '分割行    分割符为“回车键”
Dim str98(100, 10000) As String
Dim v As Integer
Dim vv As Integer
Dim p As Integer

'开始读文本
Open "D:\XXX.ini" For Binary As #7
        bit7 = Space(LOF(7))
       Get #7, , bit7
       Close #7
   Open "D:\X1.ini" For Output As #10
       cz = "W" '要查找的内容
       str7 = Split(bit7, vbCrLf)
      For c = 0 To UBound(str7)
        If str7(c) = cz Then cc = c + 1: Print #10, cc
      Next
        Close #10

  Open "D:\X1.ini" For Binary As #11
        bit11 = Space(LOF(11))
       Get #11, , bit11
       Close #11
     str11 = Split(bit11, vbCrLf)
           For p = 0 To UBound(str11)
            Next
  
   Dim jj As Integer
   Dim kk As Integer
           jj = 1
           kk = 0         
      For ll = 0 To p - 2
        Open "D:\" & ll & ".ini" For Output As #11
           For w = str11(kk) To str11(kk + 1) - 2
             str98(jj, w) = str7(w)
             Print #11, str98(jj, w)
           Next
         Close #11
         If w = Val(str11(kk + 1) - 2) Then jj = jj + 1: kk = kk + 1
   ‘  在这好想就有问题,w 的值大于 str11(kk + 1) - 2 了,使得 KK 和 JJ 的值不能增加
     Next

End Sub

[ 本帖最后由 xiao986211 于 2015-5-9 23:19 编辑 ]
2015-05-09 23:17



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-445071-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.798784 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved