Kccc

ok ive tryed this code but it dosent work,

Private Sub TextBox1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click

TextBox1.Copy()

End Sub

what i want it to do is when i click the textbox to coppy the text inside of it,



Re: Visual Basic Express Edition I need Textbox help :p

Chris

Use a richtextbox instead. Just change the multiline property to false and it looks like a textbox and offers better text editing functionality.



Re: Visual Basic Express Edition I need Textbox help :p

Dave299

Textbox1.Copy copies the currently selected text to the clipboard. However as you have put the code into the Textbox.Click event handler, as soon as you click on the textbox the selection disappears and so nothing is copied.

Try this instead:

Code Snippet

Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click

If TextBox1.Text.Length > 0 Then

Clipboard.SetText(TextBox1.Text)

End If

End Sub





Re: Visual Basic Express Edition I need Textbox help :p

BadButBit

Hi,

I'm not sure what it is you want to do but it might help you to know that you can copy the contents of the text box directly to a string

Code Snippet

Dim strText As String = textBox1.Text

hope that helps.

BadButBit





Re: Visual Basic Express Edition I need Textbox help :p

Tall Dude

Dave,

I beg to differ.

The selected text in a textbox will 'unhighlight' when you

click a button, but it is still selected.

The following will copy the selected text in a textbox to

the clipboard:

Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Copy()

End Sub






Re: Visual Basic Express Edition I need Textbox help :p

Dave299

What you say is correct but the original question was:

what i want it to do is when i click the textbox to coppy the text inside of it

and what I said was:

as soon as you click on the textbox the selection disappears and so nothing is copied





Re: Visual Basic Express Edition I need Textbox help :p

Tall Dude

Sorry I misread your post Dave.