Home > Archive > VBScript > April 2004 > Case Insensitive VBScript
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Case Insensitive VBScript
|
|
|
| Hi. I created a simple search engine on my website using ASP and
VBScript. When I post the results, I highlight the search word. My
problem is my search is case sensitive and I don't want it to be. How
can I fix this?
Here is my function... maybe you'll have a better idea.
Public Function HighlightSearchWord(sText, sHighlight)
sTempText = sText
lPosition = 1
Do While InStr(lPosition, sTempText, sHighlight) > 0
sTempText = Mid(sTempText, 1, InStr(lPosition, sTempText,
sHighlight) - 1) & "<span style='background-color: #FFFF00'>" &
Trim(sHighlight) & "</span>" & Mid(sTempText, InStr(lPosition,
sTempText, sHighlight) + Len(sHighlight))
lPosition = (InStr(lPosition, sTempText, sHighlight)) + 1
Loop
HighlightSearchWord = sTempText
End Function
Thanks,
Rick
| |
| Joe Earnest 2004-04-21, 9:30 am |
| Hi,
"RIck" <bluesbrthr@home.com> wrote in message
news:45f0255d.0404210309.1b0c6114@posting.google.com...
> Hi. I created a simple search engine on my website using ASP and
> VBScript. When I post the results, I highlight the search word. My
> problem is my search is case sensitive and I don't want it to be. How
> can I fix this?
>
> Here is my function... maybe you'll have a better idea.
>
> Public Function HighlightSearchWord(sText, sHighlight)
>
> sTempText = sText
> lPosition = 1
>
> Do While InStr(lPosition, sTempText, sHighlight) > 0
> sTempText = Mid(sTempText, 1, InStr(lPosition, sTempText,
> sHighlight) - 1) & "<span style='background-color: #FFFF00'>" &
> Trim(sHighlight) & "</span>" & Mid(sTempText, InStr(lPosition,
> sTempText, sHighlight) + Len(sHighlight))
>
> lPosition = (InStr(lPosition, sTempText, sHighlight)) + 1
>
> Loop
>
> HighlightSearchWord = sTempText
>
> End Function
>
>
> Thanks,
>
> Rick
Sounds like you need the MS CHM file WSH documentation. If you don't have
it:
http://www.microsoft.com/downloads/...&DisplayLang=en
InStr has an optional final case-insensitive (text-compare) parameter.
wscript.echo instr(1, "abcde", "CD", 1)
Or you can just like-case your search and subject strings.
instr(lPosition, lcase(sTempText), lcase(sHighlight))
Joe Earnest
| |
|
| "Joe Earnest" <joeearnestNO@SPAMqwest.netPLEASE> wrote in message news:<uP8WBk5JEHA.2556@TK2MSFTNGP11.phx.gbl>...
> Hi,
>
> "RIck" <bluesbrthr@home.com> wrote in message
> news:45f0255d.0404210309.1b0c6114@posting.google.com...
>
> Sounds like you need the MS CHM file WSH documentation. If you don't have
> it:
>
> http://www.microsoft.com/downloads/...&DisplayLang=en
>
> InStr has an optional final case-insensitive (text-compare) parameter.
>
> wscript.echo instr(1, "abcde", "CD", 1)
>
> Or you can just like-case your search and subject strings.
>
> instr(lPosition, lcase(sTempText), lcase(sHighlight))
>
> Joe Earnest
Thanks.
I had thought it was a VBScript problem since it worked in Access.
Then after I posted, I thought about the instr. I added a 1 and that
did it... Thanks for your help.
|
|
|
|
|