Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO - Simple Problem

Status
Not open for further replies.

amorous

Programmer
Sep 5, 2003
1,008
US
Hi all,

I use the following loop to display all the links to the files matching the search string entered by the user.

*******************************
Dim objFile

For Each objFile in objFolder.Files
'Print out the name

If InStr(1, objFile, strSearch, 1) Then

Response.Write &quot;<L1><A HREF=&quot;&quot;
'Response.Write objFile.Name & &quot;<BR>&quot;
End If
Next

***************************

It works perfect, But i want to display a message when there is no match saying &quot;No records were found&quot;
I am not sure how to do that.

Any Suggestions.

VJ
 
you could use a counter like so

*******************************
Dim objFile
dim iCounter
iCounter=0

For Each objFile in objFolder.Files
'Print out the name

If InStr(1, objFile, strSearch, 1) Then
iCounter=iCounter+1
Response.Write &quot;<L1><A HREF=&quot;&quot;
'Response.Write objFile.Name & &quot;<BR>&quot;
End If
Next

if iCounter=0 then response.write &quot;No records were found&quot;
***************************
 
Code:
Dim objFile
    found=false
    For Each objFile in objFolder.Files
     'Print out the name
     
     If InStr(1, objFile, strSearch, 1) Then
     found=true
     Response.Write &quot;<L1><A HREF=&quot;&quot;[URL unfurl="true"]http://myweb/documents/advance_directives/files/&quot;&...;[/URL]

     'Response.Write objFile.Name & &quot;<BR>&quot;
     End If
     if not found then Response.Write &quot;No files found&quot;
Next


________
George, M
 
Thanks a lot SarkMan,

your code worked perfectly fine. I was trying the way given by &quot;Shaddow&quot; and could not understand the strange behavior of Instr function.

thanks again.
VJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top