PrivateSubCommand1_Click()
DimaAsString
DimfilenameAsString
filename=Dir("C:\Users\ASUS\Desktop\Aegis抛料服务\CurrentSvcLog*.txt")
Open"C:\Users\ASUS\Desktop\Aegis抛料服务\"&filenameForInputAs#1
Text1(0).BackColor=&HFF&
DoWhileNotEOF(1)'循环至文件尾
LineInput#1,a'读入一行
IfInStr(a,"AttempttoReconnecttoDatabasehasfailedfor")Then
Text1(0).BackColor=&HFF00&
ExitDo
EndIf
Loop
Close#1'关闭文件
EndSub
追问
但是如果文本里有多行"Attempt to Reconnect to Database has failed for 的话,怎么让他以最新写入的那个为准??