VB Script doing a like comparison

tim_carter
tim_carter used Ask the Experts™
on
Hi Guys,

I am making a little network tool. I am looping through the network adapters. I would like to do a like comparison

So if I get an adapter that is named (local area connection) I want to know it even if it is called "local area connection 1" or local area connection 2 etc.

so something like

if adapter.Name like '%local area connection%' then.

I know that is SQL and it cant be done the same way. but how do I do that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Manager
Commented:
Vbscript Instr Function.

http://msdn.microsoft.com/en-us/library/wybb344c(v=vs.84).aspx

intFound = InStr(adapter.Name, "local area connection")
If intFound <> 0 Then


OM Gang

Author

Commented:
Thanks works great. Just have to take into account upper and lowercase
omgangIT Manager

Commented:
See the MSDN article.  The InStr function defaults to binary comparison but you can for text comparison so upper/lower case will match.

intFound = InStr(1, adapter.Name, "local area connection", 1)

OM Gang

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial