I'm trying to extract the time certain processes are running from log files similar to the attached one. Below is the code I'm using to extract the time in MM:SS format and then creating a running total of all the processes and importing it (code not included) into an access DB. Unfortunately it only works on about 30% of the files because of inconsistent formatting. Right now it is set up to identify the first '?' then the second '?' then find the '/' and extract what is between it (the time). The log file I've attached contains most (if not all) of the different layouts.
Any help greatly appreciated.
VB Code:
Dim strReadLine As String, inTaskMasterSection As Boolean
Dim pos1, pos2 As Integer, strDate As Date, strSQL As String
Dim TenCount As Integer, TimeSum As String, Time As String
The log file is consistant enough to be able to split the logfile line by the time field separator ":". It then just requires a couple of lines of code to extract the time:
VB Code:
Function GetTime(ByVal strLine As String) As String
Dim arr As Variant
Dim strRet As String
strRet = ""
arr = Split(strLine, ":")
' now extract the three fields hh:mm:ss - to return just mm:ss comment the first line