Results 1 to 2 of 2

Thread: How to put wildcards in a vbscript comparison?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2000
    Posts
    3

    Question

    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

  2. #2
    Member
    Join Date
    Aug 2000
    Location
    Florida
    Posts
    45

    How to put wildcards in a vbscript comparison?

    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.
    If I could only remember my name...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width