Upto Method Example

This example defines a pair of keyboard shortcuts that moves the insertion point in a RichTextBox control to the end of a sentence (ALT+S) or the end of a word (ALT+W). To try this example, put a RichTextBox control on a form. Paste this code into the KeyUp event of the RichTextBox control. Then run the example.

Private Sub RichTextBox1_KeyUp (KeyCode As Integer, Shift As Integer)
   If Shift = vbAltMask Then
      Select Case KeyCode
         ' If Alt+S:
         Case vbKeyS
            ' Move insertion point to the end of the sentence.
               RichTextBox1.Upto ".?!:", True, False
         ' If Alt+W:
         Case vbkeyW
            ' Move insertion point to the end of the word.
               RichTextBox1.Upto " .?!:", True, False
      End Select
   End If
End Sub