Selection from textbox

  • Thread starter Thread starter boristheblade
  • Start date Start date
B

boristheblade

I am somewhat new to vb. Is there any way to get the selection from the
a textbox?

So if I have....

"Yadda yadda yadda, blah blah blah"

In the textbox and the user selects "blah blah blah", then clicks a
button. So now I have that string in my code. Does that make sense?
I just want the selected text to be sent to the _Click() Sub. Thank
you so much for any help!!!
 
Here's some code that can do this for you:

Public gSelection as String

Private Sub SaveSelectedText()
gSelection = Text1.SelText
End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
Call SaveSelectedText
End Sub

Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single,
Y As Single)
Call SaveSelectedText
End Sub

Private Sub Button_Click()
MsgBox gSelection ' Replace this with whatever you want to do with the
text
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top