---
title: "replace - wordleft"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/13854-replace-wordleft"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "Jesper T"
published: "2002-01-18T05:25:00.000Z"
updated: "2002-01-18T09:30:00.000Z"
replies: 2
views: 171
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/13854-replace-wordleft"
---

# replace - wordleft

## #1 — Jesper T, 2002-01-18T05:25Z

Hej jag skulle vilja kombinera dessa saker i en och samma presentation, hur gör man detta lättast månne??

```

Function WordLeft(strText, intNoOfWords)	
Dim arrText, strippedText, I	
arrText = Split(strText, " ")	
If UBound(arrText) => intNoOfWords Then		
For I = 0 To (intNoOfWords - 1)			
If i = (intNoOfWords - 1) Then 				
strippedText = strippedText & arrText(i) & "..."			
Else				
strippedText = strippedText & arrText(i) & " "			
End if		
Next	
Else		
strippedText = strText	
End If	
WordLeft = strippedText
End Function
%>
```

presenteras med:

```
<%Response.write wordleft(RS("text"),5)
```

Vill kombinera med:

```
      <%response.write replace(rs("text"),Query ,"<font style='BACKGROUND-COLOR: #33CCFF'>" & Query & "</font>",1,-1,vbTextCompare)%>
```

MVH

//Jesper

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

## #2 — Erik Juhlin, 2002-01-18T06:20Z

```
<%response.write wordleft(replace(rs("text"),Query ,"<font style='BACKGROUND-COLOR: #33CCFF'>" & Query & "</font>",1,-1,vbTextCompare))%>
```

eller ännu bättre:

```
Function QueryMarked(str, sQuery)
	replace(str, sQuery , "<font style='BACKGROUND-COLOR: #33CCFF'>" & Query & "</font>", 1, -1,vbTextCompare)
End Function

response.write wordleft(QueryMarked(rs("text"),Query))
```

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

## #3 — Jesper T, 2002-01-18T09:30Z

Microsoft VBScript compilation error '800a03ea' 

Syntax error 

/sok/search.asp, line 151 

Function QueryMarked(str, sQuery)
^
Står det då!
Det som inte heller finns med i koden är ju siffran som anger meningens längd i ord.

```
<%Response.write wordleft(RS("text"),5)'<<<<<<<<<5 meningens längd i ord>>>>>>>>>>>>>>
```

//Jesper

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/13854-replace-wordleft
