VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Small searching feature

by Kaunal (1 Submission)
Category: Internet/HTML
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 1st November 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Small searching feature

Rate Small searching feature



<head>
<script language="vbscript">
Function fun()
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0

dim str
dim filename
Dim Line
str = frm.elements.txt1.value

Set FSO = CreateObject("Scripting.FileSystemObject")
Set folder = FSO.GetFolder("C:\gandhi\work")
Set files = folder.Files

if str <> "" then
For Each file in Files
 'document.Write file.Name & "<BR>"
 'Filename = Split(file.name, ".")
 'document.Write Filename(0) & "<br>"
 filename = file.name
 'document.write filename & "<br>"

 

 'if right(file.Name,3)="txt" Then
filepath = "c:\gandhi\work\" & filename
Set TextStream = FSO.OpenTextFile(Filepath, ForReading, False, TristateUseDefault)
document.Write "<pre>"
Do While Not TextStream.AtEndOfStream

Line = TextStream.ReadLine
Line = Line & vbCrlf

if instr(Line,str) > 0 then
document.write filename & ":" & Line
end if
Loop

document.Write  "</pre><hr>"
TextStream.Close
Set TextStream = nothing
 'end if
Next
else
msgbox "Insert some STRING...!"
end if

Set files = folder.Files
Set file = Nothing
Set fso = Nothing
End Function
</script>
</head>
<body>
<form name="frm">
<input type="text" name="txt1" value="">
<input type="button" name="btn" value="List" onClick="fun()">
</form>
</body>
</html>

Download this snippet    Add to My Saved Code

Small searching feature Comments

No comments have been posted about Small searching feature. Why not be the first to post a comment about Small searching feature.

Post your comment

Subject:
Message:
0/1000 characters