VBA:尝试循环播放文件并出现溢出错误

时间:2019-05-14 13:29:59

标签: vba loops overflow logfile

我正在尝试对多个日志文件进行分析。我想计算一下用户打开某个页面的频率。因此,我尝试遍历目录中的所有日志文件,并在第二个Loop中查找这些文件。 当我仅用一个文件进行测试时,在文件中查找的内部循环就起作用了。但是现在我添加了一个外循环,该外循环遍历目录中的文件,现在在Overflow error中获得了一个line 15。我是VBA的新手,但我不明白为什么会这样,因为Do-Loop的情况下,EOF(1)应该在每个文件的末尾结束。

我希望有人可以帮助我!非常感谢。

'Begin Outer-Loop
Dim FSO, MySource As Object, file As Variant
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MySource = FSO.GetFolder("n:\logs\logs\")

For Each file In MySource.Files

'Begin Inner-Loop
    intRow = 1
    Close
    Open file For Input As #1
    Do Until EOF(1)

        Line Input #1, strText
        intRow = intRow + 1

'Management-Counter
        If strText Like "*Management Overview" Then
            management_counter = management_counter + 1
        End If

'Automation-Counter
        If strText Like "*Automation Rate" Then
            automation_counter = automation_counter + 1
        End If

'Changes-Counter
        If strText Like "*Changes" Then
            changes_counter = changes_counter + 1
        End If

'Touchrate-Counter
        If strText Like "*Touchrate" Then
            touchrate_counter = touchrate_counter + 1
        End If

'Delivery Performance-Counter
        If strText Like "*4. Delivery Performance" Then
            delPerformance_counter = delPerformance_counter + 1
        End If

'Delivery Performance - Date Changes-Counter
        If strText Like "*Date Changes" Then
            dateChanges_counter = dateChanges_counter + 1
        End If

'Delivery Performance - Delivery Reliability-Counter
        If strText Like "*Delivery Reliability" Then
            delivery_counter = delivery_counter + 1
        End If

'End Inner Loop
    Loop

'End Outer Loop
Next file


End Sub

0 个答案:

没有答案