hi,
i just can't figure out what's wrong with my code.My program always come across this error, but can't understand why it has occurred. No matter in client side or at my own local also the same.
could somebody guide me on this problem.
below is my code:
Public Sub checkrecord()
Dim intIconNum As Integer
Dim strInRecord As String
Dim lFileNum As Long, lFileNum1 As Long, lfilenum2 As Long
Dim strFileName As String
Dim strCompare As String
Dim RetVal
Dim dummy As String
Dim dummy1 As String
Dim bfound As Boolean
Dim itmRecord As ListItem
On Error GoTo ErrHandler
'add the columns
frmmain.ListView1.ColumnHeaders.Clear
frmmain.ListView1.ListItems.Clear
frmmain.ListView1.VIEW = lvwReport
frmmain.ListView1.ColumnHeaders.Add , , "Station"
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Path", 3000
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Status", 1500
frmmain.ListView1.ColumnHeaders.Add , , "Last Check", 2100
frmmain.ListView1.ColumnHeaders.Add , , "Error Found", 5000
'set the image list to use for the icons
Set frmmain.ListView1.Icons = frmmain.ImageList1
Set frmmain.ListView1.SmallIcons = frmmain.ImageList1
strCompare = "exclude.ini"
'set the file name to read
strFileName = "path.ini" '<= CHANGE
'get the next available file number
lFileNum = FreeFile
RetVal = Shell(runbatch, vbMinimizedFocus)
WritePanel 2, "checking running....", "\images\access.ico"
'open the file
Open strFileName For Input As #lFileNum
'loop until the end of the file
Do While Not EOF(lFileNum)
'read the next available line
Line Input #lFileNum, strInRecord
'if the line is not empty
If strInRecord <> "[NETWORK PATH]" Then
If strInRecord <> "" Then
'split the line into an array based on the = delimiter
strFields = Split(strInRecord, "="
'choose the appropriate icon
Select Case strFields(0)
Case "MLYSITE"
intIconNum = 1
Case "MLYMTF"
intIconNum = 1
Case "MLYMAC"
intIconNum = 1
Case Else
intIconNum = 1
End Select
'add an item to the listview, with the first field as the text with the icon
Set itmRecord = frmmain.ListView1.ListItems.Add(, , strFields(0), intIconNum, intIconNum)
'add the other field to the list item
itmRecord.ListSubItems.Add , , strFields(1)
If CheckFileExist(strFields(1)) Then
If Dir(datalog, vbDirectory) = "" Then
FileSystem.MkDir datalog
End If
FileCopy strFields(1), datafile
'Delay (1)
lFileNum1 = FreeFile
Open datafile For Input As #lFileNum1
Do While Not EOF(lFileNum1)
Line Input #lFileNum1, dummy
If UCase(Mid(dummy, 1, 4)) = "ORA-" Then
'--------------------------------------------
'added by khleng
'--------------------------------------------
lfilenum2 = FreeFile
bfound = False
Open strCompare For Input As #lfilenum2
Do While Not EOF(lfilenum2)
Line Input #lfilenum2, dummy1
If UCase(Mid(dummy, 1, 9)) = UCase(dummy1) Then
bfound = True
Exit Do
End If
Loop
Close #lfilenum2
If Not bfound Then
itmRecord.ListSubItems.Add , , dummy
itmRecord.SmallIcon = "alert"
Alert.Show
Else
bfound = False
End If
End If
Loop
Close #lFileNum1
itmRecord.ListSubItems.Add 2, , "File Available"
itmRecord.ListSubItems.Add 3, , Format(Now, "dd/mm/yyyy/ hh:mm:ss AMPM"
Else
itmRecord.ListSubItems.Add 2, , "File Not Available"
itmRecord.ListSubItems.Add 3, , Format(Now, "dd/mm/yyyy/ hh:mm:ss AMPM"
itmRecord.SmallIcon = "warning"
End If
'clean up
Set itmRecord = Nothing
End If
End If
Loop
'WritePanel 3, "Next run on " & Format(Now + 1, "DD/MM/YYYY HH:MM:SS AMPM"
'close the file
Close #lFileNum
WritePanel 2, "System Started"
Exit Sub
ErrHandler:
MsgBox "CheckRecord Module Error. " + Err.Description
End Sub
thanks
antony
i just can't figure out what's wrong with my code.My program always come across this error, but can't understand why it has occurred. No matter in client side or at my own local also the same.
could somebody guide me on this problem.
below is my code:
Public Sub checkrecord()
Dim intIconNum As Integer
Dim strInRecord As String
Dim lFileNum As Long, lFileNum1 As Long, lfilenum2 As Long
Dim strFileName As String
Dim strCompare As String
Dim RetVal
Dim dummy As String
Dim dummy1 As String
Dim bfound As Boolean
Dim itmRecord As ListItem
On Error GoTo ErrHandler
'add the columns
frmmain.ListView1.ColumnHeaders.Clear
frmmain.ListView1.ListItems.Clear
frmmain.ListView1.VIEW = lvwReport
frmmain.ListView1.ColumnHeaders.Add , , "Station"
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Path", 3000
frmmain.ListView1.ColumnHeaders.Add , , "Alert Log Status", 1500
frmmain.ListView1.ColumnHeaders.Add , , "Last Check", 2100
frmmain.ListView1.ColumnHeaders.Add , , "Error Found", 5000
'set the image list to use for the icons
Set frmmain.ListView1.Icons = frmmain.ImageList1
Set frmmain.ListView1.SmallIcons = frmmain.ImageList1
strCompare = "exclude.ini"
'set the file name to read
strFileName = "path.ini" '<= CHANGE
'get the next available file number
lFileNum = FreeFile
RetVal = Shell(runbatch, vbMinimizedFocus)
WritePanel 2, "checking running....", "\images\access.ico"
'open the file
Open strFileName For Input As #lFileNum
'loop until the end of the file
Do While Not EOF(lFileNum)
'read the next available line
Line Input #lFileNum, strInRecord
'if the line is not empty
If strInRecord <> "[NETWORK PATH]" Then
If strInRecord <> "" Then
'split the line into an array based on the = delimiter
strFields = Split(strInRecord, "="
'choose the appropriate icon
Select Case strFields(0)
Case "MLYSITE"
intIconNum = 1
Case "MLYMTF"
intIconNum = 1
Case "MLYMAC"
intIconNum = 1
Case Else
intIconNum = 1
End Select
'add an item to the listview, with the first field as the text with the icon
Set itmRecord = frmmain.ListView1.ListItems.Add(, , strFields(0), intIconNum, intIconNum)
'add the other field to the list item
itmRecord.ListSubItems.Add , , strFields(1)
If CheckFileExist(strFields(1)) Then
If Dir(datalog, vbDirectory) = "" Then
FileSystem.MkDir datalog
End If
FileCopy strFields(1), datafile
'Delay (1)
lFileNum1 = FreeFile
Open datafile For Input As #lFileNum1
Do While Not EOF(lFileNum1)
Line Input #lFileNum1, dummy
If UCase(Mid(dummy, 1, 4)) = "ORA-" Then
'--------------------------------------------
'added by khleng
'--------------------------------------------
lfilenum2 = FreeFile
bfound = False
Open strCompare For Input As #lfilenum2
Do While Not EOF(lfilenum2)
Line Input #lfilenum2, dummy1
If UCase(Mid(dummy, 1, 9)) = UCase(dummy1) Then
bfound = True
Exit Do
End If
Loop
Close #lfilenum2
If Not bfound Then
itmRecord.ListSubItems.Add , , dummy
itmRecord.SmallIcon = "alert"
Alert.Show
Else
bfound = False
End If
End If
Loop
Close #lFileNum1
itmRecord.ListSubItems.Add 2, , "File Available"
itmRecord.ListSubItems.Add 3, , Format(Now, "dd/mm/yyyy/ hh:mm:ss AMPM"
Else
itmRecord.ListSubItems.Add 2, , "File Not Available"
itmRecord.ListSubItems.Add 3, , Format(Now, "dd/mm/yyyy/ hh:mm:ss AMPM"
itmRecord.SmallIcon = "warning"
End If
'clean up
Set itmRecord = Nothing
End If
End If
Loop
'WritePanel 3, "Next run on " & Format(Now + 1, "DD/MM/YYYY HH:MM:SS AMPM"
'close the file
Close #lFileNum
WritePanel 2, "System Started"
Exit Sub
ErrHandler:
MsgBox "CheckRecord Module Error. " + Err.Description
End Sub
thanks
antony