Export (0) Print
Expand All

SelLength Property

Returns the number of characters the user selects in a text-entry area of a control, or specifies the number of characters to select. Not available at design time; read/write at run time.


 [Form.]Control.SelLength[= nLength]

nLength

Specifies the number of characters selected. Selected text appears highlighted. The valid range of settings is 0 to the total number of characters in the control. Setting SelLength to less than 0 causes a run-time error.

Applies To: ComboBox | EditBox | Spinner | TextBox

Use this property with the SelStart and SelText properties for tasks such as:

  • Setting the insertion point within a string of characters.

  • Establishing an insertion range that limits where the insertion point can go.

  • Selecting a specific group of characters (substrings) in a control.

  • Clearing text.

When working with these properties, be aware of the following behaviors:

  • Setting SelLength to less than 0 causes a run-time error.

  • Setting SelStart to 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.

Community Additions

Show:
© 2014 Microsoft