ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Text Search  Cooler King at 15:41 on Thursday, February 26, 2004

Hi all,

I want to able to search through a text file and display the lines if they have a match. I've got it to work with the following code below only matches exactly what search for, if i search for say "Bloggs" it matches it but if i search for "Bloggs Marketing" it doesn't match because the actual line in the text file looks like this:

"Joe Bloggs Department of Marketing"

So heres my question how do i get it to search the whole string and return unexact matches (e.g. "Bloggs Marketing")

Thanks in advance.

Heres my code:

<% option explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Telephone Directory - Results Page</title>
<link href="domcompat.css" rel="stylesheet" type="text/css">

<div align="center">
<tr class="pdcellcolour2">
<td colspan="2"><img src="directorytitle.jpg"></td>
<tr class="pdcellcolour2">
<br><strong>Search Results for <%=Request ("SearchField")%></strong><br><br>


Dim objFSO
Set objFSO = Server.CreateObject("Scripting.fileSystemObject")

Dim strSearchField
strSearchField = Request("SearchField")

Dim objTextStream
Dim strFileContents
Dim objLine
Dim strLine
Dim strMatch
const strFileName = "e:\htdocs\Directory\directory.txt"
const fsoForReading = 1

Set objTextStream = objFSO.OpenTextFile(strFileName, fsoForReading)

Function printLine(strLine)
response.write strLine & "<br>"
end Function

While Not objTextStream.AtEndOfStream
objLine = objTextStream.ReadLine
if instr(objLine,uCase(strSearchField)) > 0 Then
End if

Set objTextStream = Nothing

Set objFSO = Nothing

CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums

Recent Forum Threads
• SoftIce Driver Suite 3.0.1
• metrowerks codewarrior 9.0
• Mapinfo.Professional.v7.0
• GardenGraphics DynaSCAPE Professional 3.02
• Embroidery Great Notions 2004 part01-74
• 0 STI.SASSPro.v2.0.0.2 working full

Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text

© Copyright 2001-2014