ComponentOne VSView 8.0
FindText Property

Finds text in the current document, returns the page and bounding rectangle (in X1,Y1,X2,Y2) for the match.

Syntax

iPage = [form!]VSPrinter.FindText(Text As String, [ CaseSensitive As Variant ], [ StartPage As Variant ], [ EndPage As Variant ], [ StartY As Variant ])

Remarks

The FindText property allows you to look for text within the current document. To retrieve text based on its position in the document, use the RetrieveText property instead.

The parameters for the FindText property are described below:

Text As String

Contains the text to be found.

CaseSensitive As Variant  (optional)

Specifies whether the control should perform a case-sensitive comparison when looking for matches. The default value for this parameter is False.

StartPage As Variant  (optional)

Specifies the page when the control should start looking for the text. The default value for this parameter is 1 (the first page).

EndPage As Variant  (optional)

Specifies the page when the control should stop looking for the text. The default value for this parameter is the value of the PageCount property (the last page).

StartY As Variant  (optional)

Specifies the position on the first page where the search should start. The default value for this parameter is 0 (the top of the page).

The property returns the number of the page where the text was found, or -1 if it was not found. The rectangle enclosing the text is returned in the X1, Y1, X2, and Y2 properties.

You may enumerate different occurrences of the same text within a document by setting the StartPage and StartY parameters. For example, the following code lists all occurrences of the string "RTF" within a document:

Dim pg& ' starting page for the search

Dim sy! ' starting top for the search

pg = 1

Do

 

  ' search for text

  pg = vp.FindText("RTF", False, pg, vp.PageCount, sy)

       

  ' if not found, bail out

  If pg <= 0 Then Exit Do

       

  ' found one

  Debug.Print "found '"; Text1.Text; "' on page "; pg; " at "; vp.X1; vp.Y1

       

  ' increment searching point to find next

  sy = vp.Y2

Loop

Note: The FindText property searches the document line by line. If a line contains the text being searched for, the rectangle returned in the X1, Y1, X2, and Y2 properties will enclose the whole line. If the text being searched for spans multiple lines, the control will not find it.

Data Type

Long

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback