Help Center

CTextRange2.MoveUntilmethod

Searches up to *Count* characters for the first character in the set of characters specified by *Cset*.

Windowsmethoddocumented

Syntax

FUNCTION MoveUntil (BYVAL Cset AS VARIANT PTR, BYVAL Count AS LONG = tomForward) AS LONG

Parameters

NameDescription
CsetThe character set used in the match. This could be an explicit string of characters or a character-set index. For more information, see Character Match Sets.
CountMaximum number of characters to move past. The default value is tomForward, which searches to the end of the story. If Count is less than zero, the search is backward starting at the start position. If Count is greater than zero, the search is forward starting at the end.

Return value

The number of characters the insertion point is moved, plus 1 for a match if Count is greater than zero, and –1 for a match if Count less than zero.

Description

Searches up to Count characters for the first character in the set of characters specified by Cset. If a character is found, the range is collapsed to that point. The start of the search and the direction are also specified by Count.

Remarks

If no character is matched, the range is unchanged.

The motion described by MoveUntil is logical rather than geometric. That is, motion is toward the end or toward the start of a story. Depending on the language, moving to the end of the story could be moving left or moving right.

For more information, see the Remarks section of Move.

The MoveStartUntil and MoveEndUntil methods move the start and end, respectively, until it finds the first character that is also in the set specified by the Cset parameter.

The MoveUntil method is similar to MoveWhile, but there are two differences. First, MoveUntil moves an insertion point until it finds the first character that belongs to the character set specified by Cset. Second, in MoveUntil the character matched counts as an additional character in the value returned. This lets you know that the character at one end of the range or the other belongs to the Cset even though the insertion point stays at one of the range ends.

For example, suppose the range, pRange, is an insertion point. To see if the character at pRange (that is, given by pRange.GetChar()) is in Cset, call

If the character is in Cset, the return value is 1 and the insertion point does not move. Similarly, to see if the character preceding pRange is in Cset, call

If the character is in Cset, the return value is –1.

The following subroutine prints all numbers in the story identified by the range, pRange.

Examples

pRange.MoveUntil(Cset, 1)

pRange.MoveUntil(Cset, -1)

SUB PrintNumbers (BYVAL pRange AS ITextRange2 PTR) pRange.SetRange(0, 0) ' // pRange = insertion point at start of story WHILE pRange.MoveUntil(C1_DIGIT, tomForward) ' // Move pRange to 1st digit in next number

DIM Delta AS LONG = pRange.MoveEndWhile(C1_DIGIT, tomForward)   ' // Select number (span of digits)
  ' PRINT ---   ' // Print it

WEND END SUB

Reference

  • Defined in AfxNova/CTextRange2.inc:553
  • Documented in Windows/WIndows Controls/RichEdit/CTextRange2 Class.md
  • Topic: CTextRange2 Class