method Edit.SetSelection ([SelStartLine as Variant], [SelStartPos as Variant], [SelEndLine as Variant], [SelEndPos as Variant])
Selects the text giving the start and end coordinates.

TypeDescription
SelStartLine as Variant A long expression that indicates the index of the line where the selection starts. If the SelStartLine parameter is negative, the selection starts from the cursor position.  
SelStartPos as Variant A long expression that indicates the index of the character in the line where the selection starts. If the SelStartPos parameter is negative, the selection starts from the cursor position. 
SelEndLine as Variant A long expression that indicates the index of the line where the selection ends. If the SelEndLine parameter is negative the control selects the text to the end.
SelEndPos as Variant A long expression that indicates the index of the character in the line where the selection ends. If the SelEndPos parameter is negative the control selects the text to the end.
Use the SetSelection method selects a text giving the start and end position. Use the CaretPos and CaretLine properties to determine the caret/cursor's position. Use the GetSelection method to retrieve the coordinates of the selection. The SelLenght property returns or sets the number of characters selected. Use the SelectLine property to select a single line. The control fires the SelChange event when the user changes the selection or the cursor's is moved. The HideSelection property specifies whether the selection in the control is hidden when the control loses the focus.

The following VB sample selects the entire text in the control:

With Edit1
    .SetSelection 0, 0, -1, -1
End With

The following VB sample selects the text from the caret position to the end:

With Edit1
    .SetSelection -1, -1, -1, -1
End With

The following C++ sample selects the entire text in the control:

m_edit.SetSelection( COleVariant( (long)0 ), COleVariant( (long)0 ), COleVariant( (long)-1 ), COleVariant( (long)-1 ) );

The following VB.NET sample selects the entire text in the control:

With AxEdit1
    .SetSelection(0, 0, -1, -1)
End With

The following C# sample selects the entire text in the control:

axEdit1.SetSelection(0, 0, -1, -1);

The following VFP sample selects the entire text in the control:

With thisform.Edit1
    .SetSelection(0, 0, -1, -1)
EndWith