VB Script doing a like comparison

Posted on 2014-08-20
Last Modified: 2014-08-20
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?
Question by:tim_carter
    LVL 28

    Accepted Solution

    Vbscript Instr Function.

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

    OM Gang
    LVL 1

    Author Closing Comment

    Thanks works great. Just have to take into account upper and lowercase
    LVL 28

    Expert Comment

    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

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now