I have a text box and i need to know how to select the highlight text in the text box, i am not sure how to do this and would like some help if you could give me any example code i would like to thank you ver much...
Rohan
Printable View
I have a text box and i need to know how to select the highlight text in the text box, i am not sure how to do this and would like some help if you could give me any example code i would like to thank you ver much...
Rohan
not sure what you mean.
To highlight text do
Code:'highlights all of the text in the text box
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
to get the highlighted text into a variable use.
Code:strText = Mid$(Text1.Text, Text1.SelStart, Text1.SelLength)
The method that you just posted didnt seem to work here is the code that i am using......
Private Sub lstCourses_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
txtsearch.Text = lstCourses.Text
txtsearch.SelStart = 0
txtsearch.SelLength = Len(txtsearch.Text)
End Sub
Iain, you can use seltext property instead to get the selected text:
Code:strText = text1.seltext
Doh, forgot all about that Kedaman. Silly me.
Any way, for a text box to be highlighted it must have the focus. So at the end of that sub do.
"Text1.SetFocus"
It works .... I didnt set the focus....thank you
Or set the textboxes "HideSelection" property to false. This will cause the text box to show what is highlighted even when it does not have the focus.
That was my next question......thank you guys