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
WINDEVWindows 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.
Remark: if this code is in the "Click" event associated with a Button control, this Button control must be an Interrupt 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
WINDEVWindows The "EDT_Edit1" control contains a character string. To retrieve the position of the cursor and the end of the selection in order to calculate the size of the selection, use the following code (in the "Click" event of an Interrupt 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