#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Location
    Terlingua, TX
    Posts
    15
    Rep Power
    0

    I don't "LIKE" this


    Okay, bad title but the subject is the Like operator in VB.
    Code:
    Function SearchDesigner(ByVal strString As String) As String
            'Dim errMsg As String
            Dim i As Integer
            Dim strstrString As String = strString.ToLower
            If Len(strString) = 0 Then Return ""
            For i = UBound(arDesigner) - 1 To 0 Step -1
                Try
                    If strstrString Like "*" & arDesigner(i, 0) & "*" Then
                        arDesignerCounter(i) += 1
                        Return arDesigner(i, 1)
                    End If
                Catch e As ArgumentException
                    'errMsg = String.Format("Line {0} {1} " & vbLf & "Contains an invalid pattern and will be skipped.", i, arDesigner(i, 0))
                    'MessageBox.Show(errMsg, "Pattern Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
                End Try
            Next
            Return ""
        End Function
    I've just parsed my way through 225,000 font files. Most of the time this works as I expect but upon occasion (1,500 more or less out of the 225,000 files) it doesn't.

    For example: strString = "(c) daisuke sugisawa001.00'"
    The array I'm parsing through, in part, looks like:
    DadoQueiroz Dado Queiroz
    Daisuke Monma Daisuke Monma
    daisuke sugisawa Daisuke Sugisawa
    Dale R. Kramer Dale R Kramer
    dale schumacher Dale Schumacher
    It should have been true only on the middle line, since nothing that I can see matches til that point.

    and the last three lines of the array look like:
    Typographer?s Edition (93) Typographers Edition (93)
    Typographer?s Edition \(93\) Typographers Edition (93)
    Typographer?s Edition (94) Typographers Edition (94)
    Like is returning true ( a match ) on the last line ... and I can't see why. Anyone?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Location
    Terlingua, TX
    Posts
    15
    Rep Power
    0
    Bump??
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    14
    Rep Power
    0
    I'm not sure if this will help you, but to test out your logic,
    I tried using the search part of your code as follows :

    Code:
            Dim i As Integer
            Dim strString As String = TextBox1.Text.ToLower
    
            For i = 0 To ListBox1.Items.Count - 1
                arDesigner(i) = ListBox1.Items(i).ToString
            Next
    
            For i = UBound(arDesigner) - 1 To 0 Step -1
                If strString Like "*" & arDesigner(i) & "*" Then
                    MessageBox.Show(arDesigner(i))
                End If
            Next
    And made strString = "(c) daisuke sugisawa001.00" and the following as list items :

    DadoQueiroz
    Daisuke Monma
    daisuke sugisawa
    Dale R. Kramer
    dale schumacher
    Typographer?s Edition (93)
    Typographer?s Edition \(93\)
    Typographer?s Edition (94)

    I only got the one match on item 3.

    cheers,

    argee

IMN logo majestic logo threadwatch logo seochat tools logo