Private Sub Command1_Click()
Dim a As String
Dim filename As String
filename = Dir("C:\Users\ASUS\Desktop\Aegis 抛料服务\CurrentSvcLog*.txt")
Open "C:\Users\ASUS\Desktop\Aegis 抛料服务\" & filename For Input As #1
Text1(0).BackColor = &HFF&
Do While Not EOF(1) '循环至文件尾
Line Input #1, a '读入一行
If InStr(a, "Attempt to Reconnect to Database has failed for ") Then
Text1(0).BackColor = &HFF00&
Exit Do
End If
Loop
Close #1 '关闭文件
End Sub
追问
但是如果文本里有多行"Attempt to Reconnect to Database has failed for 的话,怎么让他以最新写入的那个为准??