Visual Basic Reference
SelLength, SelStart, SelText Properties (ActiveX Controls)
SelLength returns or sets the number of characters selected.
SelStart returns or sets the starting point of text selected; indicates the position of the insertion point if no text is selected.
SelText returns or sets the string containing the currently selected text; consists of a zero-length string ("") if no characters are selected.
These properties aren't available at design time.
Syntax
object**.SelLength** [**=**number]
object**.SelStart** [**=**index]
object**.SelText** [**=**value]
The SelLength, SelStart, and SelText property syntaxes have these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
number | A numeric expression specifying the number of characters selected. For SelLength and SelStart, the valid range of settings is 0 to text length the total number of characters in the edit area of a ComboBox or TextBox control. |
index | A numeric expression specifying the starting point of the selected text, as described in Settings. |
value | A string expression containing the selected text. |
Remarks
Use these properties for tasks such as setting the insertion point, establishing an insertion range, selecting substrings in a control, or clearing text. Used in conjunction with the Clipboard object, these properties are useful for copy, cut, and paste operations.
When working with these properties:
Setting SelLength less than 0 causes a run-time error.
Setting SelStart greater than the text length sets the property to the existing text length; changing SelStart changes the selection to an insertion point and sets SelLength to 0.
Setting SelText to a new value sets SelLength to 0 and replaces the selected text with the new string.