---
title: "Kan någon detta !"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/97732-kan-någon-detta"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "ragnared"
published: "2004-02-19T15:52:34.000Z"
updated: "2004-02-19T17:06:33.000Z"
replies: 5
views: 318
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/97732-kan-någon-detta"
---

# Kan någon detta !

## #1 — ragnared, 2004-02-19T15:52Z

Kan man lägga till i detta script att när man söker så ska det komma fram max 50 sökord och inte som det gör nu att om man söker på bokstaven (a) så kommer typ 100 stycken fram. kan man begränsa detta det behöver inte kommma i någon speciell ordning. 

Så här ser scriptet ut:::

		\<form id=form onSubmit="return form_validator(this)" action="sok.asp?do=sok" method=POST\>

  Enter search:
  \<input type="text" name="searchtext" size="37"\> &nbsp; 
 
	\<input type="submit" value="- search -"  name="B1"\>
\</form\>

\<%If Request.QueryString("do") = "sok" Then%\>

\<b\>Search results for: \<%=Request("SearchText")%\>\</b\>\<br\>

\<%Const fsoForReading = 1

'###################################################
'-------MAPPEN FILERNA LIGGER I SOM DU SKA SÖKA BLAND------------
'###################################################

Mappen = Server.MapPath("storagearchive")
Mappen = Server.MapPath("uploads")
MappUrl = Mid(Mappen, InStrRev(Mappen, "\\") + 1)

strSearchText = Request("SearchText")
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Mappen)

bolFileFound = False

For Each objFile in objFolder.Files
  If Response.IsClientConnected then
    If InStr(1,objFile.Name,strSearchText,1) then
       Response.Write "\<b\>»\</b\> " & objFile.Name & "\</a\>\<br\>"
       bolFileFound = True
    End If
  End If
Next

if Not bolFileFound then Response.Write "Nothing found..."

Set objFolder = Nothing
Set objFSO = Nothing%\>

\<%End If%\>

Permalänk: https://www.webforum.nu/p/97732

## #2 — cyprys, 2004-02-19T16:16Z

```
Dim i 
i = 0
For Each objFile in objFolder.Files
  If Response.IsClientConnected then
    If InStr(1,objFile.Name,strSearchText,1) then
Response.Write "<b>»</b> " & objFile.Name & "</a><br>"
    bolFileFound = True
    i = i - -1
    if i = 50 then exit for
  End If
End If
Next
```

Permalänk: https://www.webforum.nu/p/1280097

## #3 — J.N., 2004-02-19T16:16Z

HEJ!

Lägg in en räknare som går till 50.

```
For Each objFile in objFolder.Files AND i < 50

eller

For Each objFile in objFolder.Files
 Do until i > 50
    kod
 i = i + 1
 Loop
Next
```

Bonus:
Använd \[kod\]-taggarna!

Permalänk: https://www.webforum.nu/p/1280099

## #4 — LarsG, 2004-02-19T16:18Z

```
dim cnt
cnt = 1
For Each objFile in objFolder.Files
     If Response.IsClientConnected then
         If InStr(1,objFile.Name,strSearchText,1) then
             Response.Write "<b>»</b> " & objFile.Name _
          & "</a><br>"
             bolFileFound = True
              if  Cnt = 50 then exit for
             Cnt = Cnt + 1
         End If
    End If
Next
```

Permalänk: https://www.webforum.nu/p/1280101

## #5 — ragnared, 2004-02-19T17:02Z

Tack snälla ni för hjälpen !!!

Permalänk: https://www.webforum.nu/p/1280123

## #6 — @nders, 2004-02-19T17:06Z

Det kan vara bra att markera *det inlägg* som löste problemet för dig. Det blir då lättare för andra att hitta lösning på liknande problem.

Permalänk: https://www.webforum.nu/p/1280124

---

Tråden på webben: https://www.webforum.nu/amne/asp/97732-kan-någon-detta
