回复 3楼 风吹过b
以下可以处理,就是速度非常的慢,请教快速处理方法。
Private Sub Command1_Click()
'/////////////////////////////////////////////////////////////////////////
MsgBox "选择输出路径"
With Application.FileDialog(msoFileDialogFolderPicker)
If (.Show = -1) Then
mypathout = .SelectedItems(1)
End If
End With
If mypathout = "" Then
Exit Sub
End If
mypathout = mypathout + "\"
'///////////////////////////////////////////////////////////////////////////
Dim sig1(65535) As Variant
Dim sig2(65535) As Variant
Dim sig3(65535) As Variant
Dim sig4(65535) As Variant
Dim sig5(65535) As Variant
Dim sig6(65535) As Variant
Dim sig7(65535) As Variant
Dim sig8(65535) As Variant
Dim sig9(65535) As Variant
Dim sig10(65535) As Variant
Dim sig11(65535) As Variant
Dim sig12(65535) As Variant
g1 = 1
g2 = 1
g3 = 1
g4 = 1
g5 = 1
g6 = 1
g7 = 1
g8 = 1
g9 = 1
g10 = 1
g11 = 1
g12 = 1
MsgBox "选择统计文件"
With Application.FileDialog(msoFileDialogFolderPicker)
If (.Show = -1) Then
MyPath = .SelectedItems(1)
End If
End With
If MyPath = "" Then
Exit Sub
End If
MyPath = MyPath + "\"
MyName = Dir(MyPath, vbDirectory)
Do While MyName <> ""
If MyName <> "." And MyName <> ".." Then
Open MyPath + MyName For Input As #1
Do While Not EOF(1)
Line Input #1, mmlline
If InStr(mmlline, "网元") > 0 Then
Line Input #1, mmlline
If InStr(mmlline, "CD-RNC") Then
GoTo qqq
End If
nodebname = Trim(Mid(mmlline, 2, 50))
Line Input #1, mmlline
Line Input #1, mmlline
If InStr(mmlline, "网元断连") <= 0 And InStr(mmlline, "网元响应MML命令超时") <= 0 And InStr(mmlline, "没有权限") <= 0 Then
Line Input #1, mmlline
Line Input #1, mmlline
Line Input #1, mmlline
Line Input #1, mmlline
Line Input #1, mmlline
If InStr(mmlline, "没有查到相应的结果") > 0 Then
GoTo qqq
End If
Line Input #1, mmlline
Line Input #1, mmlline
If InStr(mmlline, "=") <= 0 Then
If InStr(mmlline, "相关DSP号") > 0 Then
Line Input #1, mmlline
Line Input #1, mmlline
qiu:
mmlline1 = mmlline
For j = 50 To 1 Step -1
mmlline1 = Replace(Trim(mmlline1), Application.Rept(" ", j), "|")
Next
a = Split(mmlline1, "|")
sig1(g1) = nodebname
sig2(g2) = a(0)
sig3(g3) = a(1)
sig4(g4) = a(2)
sig5(g5) = a(3)
sig6(g6) = a(4)
sig7(g7) = a(5)
sig8(g8) = a(6)
sig9(g9) = a(7)
sig10(g10) = a(8)
sig11(g11) = a(10)
sig12(g12) = a(11)
g1 = g1 + 1
g2 = g2 + 1
g3 = g3 + 1
g4 = g4 + 1
g5 = g5 + 1
g6 = g6 + 1
g7 = g7 + 1
g8 = g8 + 1
g9 = g9 + 1
g10 = g10 + 1
g11 = g11 + 1
g12 = g12 + 1
Line Input #1, mmlline
If InStr(mmlline, "结果个数") <= 0 Then
GoTo qiu
End If
Else
Line Input #1, mmlline
Line Input #1, mmlline
qiu1:
mmlline1 = mmlline
For j = 50 To 1 Step -1
mmlline1 = Replace(Trim(mmlline1), Application.Rept(" ", j), "|")
Next
a = Split(mmlline1, "|")
sig1(g1) = nodebname
sig2(g2) = a(0)
sig3(g3) = a(1)
sig4(g4) = a(2)
sig5(g5) = a(3)
sig6(g6) = a(4)
sig7(g7) = a(5)
sig8(g8) = a(6)
sig9(g9) = a(7)
sig10(g10) = a(8)
sig11(g11) = a(10)
sig12(g12) = a(11)
g1 = g1 + 1
g2 = g2 + 1
g3 = g3 + 1
g4 = g4 + 1
g5 = g5 + 1
g6 = g6 + 1
g7 = g7 + 1
g8 = g8 + 1
g9 = g9 + 1
g10 = g10 + 1
g11 = g11 + 1
g12 = g12 + 1
Line Input #1, mmlline
If InStr(mmlline, "结果个数") <= 0 Then
GoTo qiu1
End If
End If
Else
sig1(g1) = nodebname
sig2(g2) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig3(g3) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig4(g4) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig5(g5) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig6(g6) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig7(g7) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig8(g8) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig9(g9) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig10(g10) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
If Len(mmlline) > 12 Then
Line Input #1, mmlline
sig11(g11) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig12(g12) = Trim(Split(mmlline, "=")(1))
Else
sig11(g11) = Trim(Split(mmlline, "=")(1))
Line Input #1, mmlline
sig12(g12) = Trim(Split(mmlline, "=")(1))
End If
g1 = g1 + 1
g2 = g2 + 1
g3 = g3 + 1
g4 = g4 + 1
g5 = g5 + 1
g6 = g6 + 1
g7 = g7 + 1
g8 = g8 + 1
g9 = g9 + 1
g10 = g10 + 1
g11 = g11 + 1
g12 = g12 + 1
End If
End If
End If
If InStr(mmlline, "仍有后续报告输出") > 0 Then
For w = 1 To 11
Line Input #1, mmlline
Next
gg = InStr(mmlline, "相关DSP号")
Line Input #1, mmlline
Line Input #1, mmlline
If gg > 0 Then
GoTo qiu
Else
GoTo qiu1
End If
End If
qqq:
Loop
Close #1
End If
MyName = Dir
Loop
'//////////////////////////////////////////////////////////////////
txtline = "站名" & "|" & "小区设备ID" & "|" & "载波资源ID" & "|" & "相关BBP槽号" & "|" & "相关DSP号" & "|" & "相关DSPGRP号" & "|" & "频点" & "|" & "载波服务类型" & "|" & "载波状态" & "|" & "载波类型" & "|" & "操作态" & "|" & "可用态" & vbCrLf
For i = 1 To g1
txtline = txtline & sig1(i) & "|" & sig2(i) & "|" & sig3(i) & "|" & sig4(i) & "|" & sig5(i) & "|" & sig6(i) & "|" & sig7(i) & "|" & sig8(i) & "|" & sig9(i) & "|" & sig10(i) & "|" & sig11(i) & "|" & sig12(i) & vbCrLf
Next
Dim fso1 As Object
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set Ts1 = fso1.CreateTextFile("D:\Q结果.txt")
Ts1.WriteLine txtline
Ts1.Close
Workbooks.OpenText FileName:="D:\Q结果.txt", Origin:=936 _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=True, OtherChar:="|", FieldInfo:=Array(Array(1, 1 _
), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1)), _
TrailingMinusNumbers:=True
ActiveWorkbook.SaveAs FileName:=mypathout + "基站载波统计结果" & Date & ".xlsx", _
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
Kill "D:\q结果.txt"
MsgBox "统计完成!结果保存在:" & mypathout & "基站载波统计结果" & Date & ".xlsx"
End Sub