PDA

Click to See Complete Forum and Search --> : How to put wildcards in a vbscript comparison?


Myph
Nov 2nd, 2000, 12:38 PM
I have this code:
'**********************************************************
objRS.Open "Select Machine_Name, Login_User FROM Location_Chart WHERE Machine_Name = '"&GetMachineName&"'",dbConn
strLoggedInUser = Trim(Lcase(objRS("Login_User")))
strUserSearch = Trim(Lcase(Request("strUserSearch")))
IF strLoggedInUser = strUserSearch THEN
strBGColor = "tan"
END IF
'*********************************************************

Let's say that the value of strLoggedInUser is Draughn.
I want it so that even if strUserSearch is "rau" it will still find the word Draughn.

I thought that it would be something like:
'******************************************************
IF strLoggedInUser LIKE "%" & strUserSearch & "%" THEN
strBGColor = "tan"
END IF
'******************************************************
but that is not working properly. I have tried it with "*" and '%%" nothing seems to work right. can someone help me with this? Thanks

dadames
Nov 2nd, 2000, 01:14 PM
Try the InStr function. It returns an integer indicating the position for the first occurrence of a sub string within a string. If the returned value is > 1 you have a match.