MatchLength Property

Returns the length of the current match, in characters.

Syntax

val& = [form!]VSFlexString.MatchLength([ MatchIndex As Long ])

Remarks

Looking for a pattern in a string may result in several matches. You can retrieve information about each match using the MatchLength, MatchStart, and MatchString properties.

The optional parameter MatchIndex should be a number between zero and MatchCount - 1. The default value is the current value of the MatchIndex property.

The MatchStart and MatchLength properties are useful when you need to work on the original string stored in the Text property. For example, the code below searches for a pattern in a RichEdit control and then underlines each match:

    fs = rtfEdit.Text

    fs.Pattern = txtPattern

    For i = 0 To fs.MatchCount - 1

        rtfEdit.SelStart = fs.MatchStart(i)

        rtfEdit.SelLength = fs.MatchLength(i)

        rtfEdit.SelUnderline = True

    Next

Data Type

Long

See Also

VSFlexString Control