% '******************************************************* '* ASP 101 Sample Code - http://www.asp101.com/ * '* * '* This code is made available as a service to our * '* visitors and is provided strictly for the * '* purpose of illustration. * '* * '* http://www.asp101.com/samples/license.asp * '* * '* Please direct all inquiries to webmaster@asp101.com * '******************************************************* %>
" & vbCrLf
Do While Not objTextFile.AtEndOfStream
intLineNumber = intLineNumber + 1
strReadLineText = objTextFile.ReadLine
If strSearchText <> "" And InStr(strReadLineText, strSearchText) > 0 Then
strReadLineText = Replace(strReadLineText, _
strSearchText, _
"" & strSearchText & "")
strLineNumbers = strLineNumbers & intLineNumber & ", "
End If
Response.Write strReadLineText & vbCrLf
Loop
Response.Write "
" & vbCrLf
' Remove the last separator (", ") from our line number list.
If Len(strLineNumbers) > 2 Then
strLineNumbers = Left(strLineNumbers, Len(strLineNumbers) - 2)
End If
' Close and release file references
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
Response.Write "The text searched for was found on the following lines in the file: " Response.Write strLineNumbers & "
" %>