VBS using LIKE to compare strings “Sub or Function not defined”

前端 未结 4 1759
一整个雨季
一整个雨季 2020-12-10 20:32

I\'m trying to make a script to connect a network printer to a user computer. The script uses the computer name who needs the printer as a parameter.

Printers names

4条回答
  •  一向
    一向 (楼主)
    2020-12-10 21:07

    I used the following alternative (VBScript Regular Expressions)… Uses slightly different syntax from LIKE but easiest solution to make a match successfully similar to LIKE operator.

    dim regExp
    set regExp=CreateObject("VBScript.RegExp")
    regExp.IgnoreCase = true
    regExp.Global = true
    regxp.Pattern = ".*Test Pattern.*" ' example only, basic pattern
    
    if regExp.Test(MyString) then
        ' match successful
    end if
    

提交回复
热议问题