Why doesn't this fuzzy search in vb6 work?  How can I change this to make it work?

Posted on 2007-10-09
Last Modified: 2007-10-10
Why doesn't this fuzzy search in vb6 work?  How can I change this to make it work?

If "cerebral" Like "*cere" Then
MsgBox "these are the same"
End If
Question by:blackbookcoder2
    LVL 38

    Accepted Solution

    The wildcard * is a stand in for other characters... in this case, any other characters.  These would be true:

    Private Sub Command1_Click()

        If "cerebral dancing monkey" Like "cere*" Then
            MsgBox "alike"
        End If
            If "cerebral" Like "cere*" Then
            MsgBox "alike"
        End If

        If "cereal" Like "cere*" Then
            MsgBox "alike"
        End If

    End Sub

    Putting the * at the beginning of the string would match any character at the beginning of the string.  For example:

    If "This is a test" Like "*a test" Then
      Msgbox "alike"
    End If

    But an asterix at the beginning cannot match characters at the end of the string as in your example...

    Author Comment

    PaulHews, thanks for your help.  Sincerely, blackbookcoder2

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    737 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

    22 Experts available now in Live!

    Get 1:1 Help Now