asp.net.ph

Skip Navigation Links

findText Method

DHTML Methods


Searches for text in the document and positions the start and end points of the range to encompass the search string.

Syntax

bFound = TextRange.findText ( 
   sText [ ,  iSearchScope ] [ ,  iFlags ] ) 
Parameters

sText Required. Text to find.
iSearchScope Optional. Number of characters to search from the starting point of the range. A positive integer indicates a forward search; a negative integer indicates a backward search.
iFlags Optional. One or more of the following flags indicating the type of search:

2 Match whole words only.
4 Match case.


Return Value

Boolean. Returns TRUE if the search text is found, or FALSE otherwise.

Remarks

A range has two distinct states: degenerate and nondegenerate. Analogous to a text editor, a degenerate range is like a text editor caret ( insertion point ); it does not actually select any characters. Instead it specifies a point between two characters. A degenerate range's end points are effectively next to each other. On the other hand, a nondegenerate range is like a text editor selection. A certain amount of text is selected, and the end points of the range are not next to each other.

The value passed for the iSearchScope parameter controls the part of the document, relative to the range, that is searched. The behavior of the findText method is dependent upon the state ( degenerate or nondegenerate ).

  • If the range is degenerate, passing a large positive number will cause the text to the right of the range to be searched. Passing a large negative number causes the text to the left of the range to be searched.
  • If the range is nondegenerate, passing 0 will cause only the text "selected" by the range to be searched.
  • For a nondegenerate range passing a large positive number will cause the text to the right of the start of the range to be searched.
  • For a nondegenerate range passing a large negative number will cause the text to the left of the end of the range to be searched.

This feature might not be available on non-Win32® platforms. See the Microsoft® Knowledge Base for the latest information on Internet Explorer® cross-platform compatibility.

Example

The following example creates a TextRange over the body of the document and searches for text with various flag combinations. The results are indicated in the code comments.

Sample Code

Applies To

TextRange



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note