PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Example 1: Positioning the cursor on a word
  • Example 2: Calculating the size of the selected string
Example 1: Positioning the cursor on a word
WINDEVWindowsWindows Mobile Once we've searched for a word in a character string (found in the "EDT_Edit1" control), the code used to select this word is as follows.
Note: if this code is found in the click code of a button, this button must be an Interruption button.
Word is string = "Word"
n is int
n = Position(EDT_Edit1, Word,1)
IF n <> 0 THEN
        // Position the cursor at the beginning of the word
        EDT_Edit1..Cursor = n
        // Select the word
        EDT_Edit1..CursorEnd = n + Length(Word)
END
Example 2: Calculating the size of the selected string
WINDEVWindowsWindows Mobile The "EDT_Edit1" control contains a character string. To retrieve the position of the cursor and the end position of the selection in order to calculate the size of the selection, use the following code (in the click code of an Interruption button for example).
n, n2 are int
n = EDT_Edit1..Cursor
n2 = EDT_Edit1..CursorEnd
Info("Size of the selected string: " + (n2-n))
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment