Results 1 to 2 of 2

Thread: MySQL VB6 and Regex

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    18

    MySQL VB6 and Regex

    Hi,

    I will try and explain my problem to the best of my ability. I have some code that access' 2 MySQL tables and retrives some values, one of these being a set of regular expressions, and the other being the stings that i wish to test the regular expression on. The problem occurs when i try and loop around these values, my first loop is to loop around the regular expressions, and the sencond loop is to loop around the strings to match against the regular expression.

    Code:
    Do Until rdoRsReg.EOF
        With rdoRsReg
        
            objRE.Pattern = !Regexpression
            objRE.Global = True
        
            Do Until rdoRS.EOF
                
                With rdoRS
                
                        Set objMatches = objRE.Execute(!Query_text)
                        If objMatches.count > 0 Then
                            For Each objMatch In objMatches
                              Text2.Text = Text2.Text + vbCrLf & !Query_ID & objMatch.Value '"Sentence end found at position " & objMatch.FirstIndex
                            Next
                            Else
                                Text2.Text = Text2.Text & "The expression was not found"
                            End If
                        
                    rdoRS.MoveNext
                
                End With
            Loop
        
        rdoRsReg.MoveNext
        
        End With
    Loop
    When i step through the debugger is say i am using an invalid use of null on the following line :

    Code:
    Set objMatches = objRE.Execute(!Query_text)
    To begin with the !Query_text is holding a correct value from the table, but when i step past it, it the turns to null and errors.

    Any help would be great

    I hope i have explained my problem clearly, if not please ask for more detail

  2. #2
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313

    Re: MySQL VB6 and Regex

    So are you saying that !QueryText changes to NULL during the iteration (i.e. before the MoveNext) or as you loop through the records?
    Could you try a check such as:
    VB Code:
    1. If Not IsNull(!Query_text) then
    2.     'do the regex check here
    3. End If
    Have you tried assigning the value to a local variable?
    VB Code:
    1. Dim strTest as string
    2. strTest = !Query_text
    3. Set objMatches = objRE.Execute(strTest)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width