以下是引用宋政林在2021-1-27 16:04:47的发言:
那能實現此功能嗎?
1,當實際應用中,VB6的程式是一直開啟的,此時...ICT測試機會間隔幾秒就會有新的日誌寫入,是否能做到實時檢查新日誌。
那能實現此功能嗎?
1,當實際應用中,VB6的程式是一直開啟的,此時...ICT測試機會間隔幾秒就會有新的日誌寫入,是否能做到實時檢查新日誌。
程序代码:Dim WithEvents Timer1 As Timer
Private Sub Form_Load()
'用代码创建一个Timer1控件,不用往窗体拖Timer1控件
Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Dim ymd As String '日期变量
Dim FileName As String '文件名变量
Dim Str As String '读取到的数据内容变量
Dim FilePath As String '完整的文件名变量
FilePath = "C:\ew518fe\ES340A\" '日志.LOG的文件夹
ymd = Year(Date) & String(2 - Len(Month(Date)), "0") & Month(Date) & String(2 - Len(Day(Date)), "0") & Day(Date)
FileName = "ODBC" & ymd & ".LOG"
'Print FileName
Cls '清除窗体上一次显示的信息
If Dir(FilePath, vbDirectory + vbHidden) = "" Then
Form1.Print "日志文件目录不存在!"
ElseIf Dir(FilePath & FileName) = "" Then
Form1.Print "今天没有新日志文件!"
Else
Open FilePath & FileName For Input As #1
While Not EOF(1)
Line Input #1, Str
a = a + 1
Wend
'DoEvents
Close #1
If Str <> "" Then
Form1.Print Str
Else
Form1.Print "有日志文件,但日志内容为空!"
End If
End If
End Sub

心生万象,万象皆程序!
本人计算机知识网:http://bbs.为防伸手党,本站已停止会员注册。







