The Text box has a few properties that allow you to get and set the selected text. These are:
SelText
SelLength
SelStart
SelText returns the selected text. SelLength returns the length of the selection. SelStart returns the startiong position of the selection. The following code sets Text1.Text to "I live in England", and then selects England.
Sub Command1_Click()
Text1.Text = "I live in England"
Text1.SelStart = InStr(Text1, "England")
Text1.SelLength = 7
End Sub
Comments