property Expression.SelText as String
Returns or sets the string containing the currently selected text.

TypeDescription
String A string expression that indicates the  current selection's text.

Returns the text that the user selected in a text-entry area of a control, or returns an empty string ("") if no characters are selected. Specifies the string containing the selected text. Not available at design time; read-write at run time. The SelStart property returns or sets the starting point of text selected; indicates the position of the insertion point if no text is selected. The control fires the SelChange event when the user changes the selection.

The following VB sample displays the selected text when the user changes it:

Private Sub Expression1_SelChange()
    If Not Expression1.SelText = "" Then
        Debug.Print Expression1.SelText
    End If
End Sub

The following C++ sample displays the selected text when the user changes it:

void OnSelChangeExpression1() 
{
	OutputDebugString( m_expression.GetSelText() );
}

The following VB.NET sample displays the selected text when the user changes it:

Private Sub AxExpression1_SelChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxExpression1.SelChange
    With AxExpression1
        Debug.WriteLine(.SelText)
    End With
End Sub

The following C# sample displays the selected text when the user changes it:

private void axExpression1_SelChange(object sender, EventArgs e)
{
	System.Diagnostics.Debug.WriteLine(axExpression1.SelText);
}

The following VFP sample displays the selected text when the user changes it:

*** ActiveX Control Event ***

with thisform.Expression1
	wait window nowait .SelText
endwith