Span selects text in a RichEdit control based on a set of specified characters. UpTo moves the insertion point up to, but not including, the first character that is a member of the specified character set.
RichEdit.Span(characterset[,forward = 1] [,negate = 0])
RichEdit.UpTo(characterset [,forward = 1] [,negate = 0])
characterset:sexp
forward, negate:Boolean exp
The characterset specifies the set of characters to look for when extending the selection (Span) or moving the selection point (UpTo), based on the optional value of negate.
By default negate = False and Span selects the characters which appear in the characterset argument. The selection stops at the first character found that does not appear in the characterset argument.
Setting negate = True will select the characters which do not appear in the characterset argument. The selection stops at the first character found that appears in the characterset argument.
For UpTo (negate = 0) the characters specified in the characterset argument are used to move the insertion point. Setting negate = True will use the characters specified in the characterset argument to move the insertion point.
Sub rtf1_KeyUp(Code&, Shift&)
Select Code
Case Asc("S") ' Alt+S or Ctrl+S
' Move insertion point to the end of the sentence.
If Shift = 4 rtf1.UpTo ".?!:"
' Select to the end of the sentence.
If Shift = 2 rtf1.Span ".?!:", True, True
Case Asc("W") ' Alt+W or Ctrl+S
' Move insertion point to the end of the word.
If Shift = 4 rtf1.UpTo " ,;:.?!"
' Select to the end of the word.
If Shift = 2 rtf1.Span " ,;:.?!", True, True
End Select
End If
{Created by Sjouke Hamstra; Last updated: 23/10/2014 by James Gaite}