VB Script doing a like comparison

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?
LVL 1
tim_carterAsked:
Who is Participating?
 
omgangIT ManagerCommented:
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
0
 
tim_carterAuthor Commented:
Thanks works great. Just have to take into account upper and lowercase
0
 
omgangIT ManagerCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.