1、要看文本是纯英文还是中英文混合,纯英文稍简单些,中英混合则需要定义一个二维数组存储统计结果。
2、假设文本文件为c:\a.txt,完成你所需功能的代码如下:
Dim a As String, b As String, c() As String
b = ""
Open "c:\a.txt" For Input As #1
While Not EOF(1)
Line Input #1, a
c = Split(a, "SUMMARY:")
If UBound(c) = 1 Then b = b & c(1) & ","
Wend
Close #1
Print b
'结果在字符串变量b中,如有多个则会用逗号隔开,比如我的文件内容如下,运行结果为:4234324,gdfgerg,xxxxxxxxx,
TABLE: "BRIDGE DESIGN PREFERENCES - JTG-D62-2004"
Importance="Class II" FactLim=1
SUMMARY:4234324
TABLE: "BRIDGE DESIGN PREFERENCES - AASHTOLRFD07"
HingeOpt="Auto: AASHTO/Caltrans Hinge"
TABLE: "JOINT COORDINATES"
Joint=1 CoordSys=GLOBAL CoordType=Cartesian XorR=-3 Y=-3 Z=0 SpecialJt=No GlobalX=-3 GlobalY=-3 GlobalZ=0
Joint=2 CoordSys=GLOBAL CoordType=Cartesian XorR=-3 Y=-3 Z=3 SpecialJt=No GlobalX=-3 GlobalY=-3 GlobalZ=3
Joint=3 CoordSys=GLOBAL CoordType=Cartesian XorR=-3 Y=3 Z=0 SpecialJt=No GlobalX=-3 GlobalY=3 GlobalZ=0
Joint=4 CoordSys=GLOBAL CoordType=Cartesian XorR=-3 Y=3 Z=3 SpecialJt=No GlobalX=-3 GlobalY=3 GlobalZ=3
Joint=5 CoordSys=GLOBAL CoordType=Cartesian XorR=3 Y=-3 Z=0 SpecialJt=No GlobalX=3 GlobalY=-3 GlobalZ=0
Joint=6 CoordSys=GLOBAL CoordType=Cartesian XorR=3 Y=-3 Z=3 SpecialJt=No GlobalX=3 GlobalY=-3
SUMMARY:gdfgerg
GlobalZ=3
Joint=7 CoordSys=GLOBAL CoordType=Cartesian XorR=3 Y=3 Z=0 SpecialJt=No GlobalX=3 GlobalY=3 GlobalZ=0
Joint=8 CoordSys=GLOBAL CoordType=Cartesian XorR=3 Y=3 Z=3 SpecialJt=No GlobalX=3 GlobalY=3
SUMMARY:xxxxxxxxx
GlobalZ=3