Use this function within your record return page :
Expand|Select|Wrap|Line Numbers
- 'Highlight searched for text function
- Function Highlight(strText, strFind, strBefore, strAfter)
- Dim nPos
- Dim nLen
- Dim nLenAll
- nLen = Len(strFind)
- nLenAll = nLen + Len(strBefore) + Len(strAfter) + 1
- Highlight = strText
- If nLen > 0 And Len(Highlight) > 0 Then
- nPos = InStr(1, Highlight, strFind, 1)
- Do While nPos > 0
- Highlight = Left(Highlight, nPos - 1) & _
- strBefore & Mid(Highlight, nPos, nLen) & strAfter & _
- Mid(Highlight, nPos + nLen)
- nPos = InStr(nPos + nLenAll, Highlight, strFind, 1)
- Loop
- End If
- End Function
To implement it within the page use the following code around your recordset return, in this case the text would be highlighted in bold red with a yellow background. The MYDATARETURN is what the database is giving back to you, the THESTRINGSEARCHEDFOR is a variable input which you will have used in your search.
Expand|Select|Wrap|Line Numbers
- <%=Highlight(RS1("MYDATARETURN"),""&THESTRINGSEARCHEDFOR&"", "<b><font color=red><span style='background-color: yellow'>", "</span></font></b>")%>