Need help with Copy and Paste
VB 2008
I'm trying to highlight some text in a web browser and copy and paste it into a textbox. When I run the first two commands below and manually click on the textbox and paste, the text is copied correctly.
WebBrowser1.Focus()
SendKeys.Send("^{INSERT}")
I tried the following possible commands to program that function but none of it works.
'TextBox3.Text = Clipboard.GetText()
'TextBox3.Text = Clipboard.GetDataObject.
'Dim iData As IDataObject = Clipboard.GetDataObject()
'TextBox3.Text = CType(iData, String)
'Dim iData As IDataObject = Clipboard.GetDataObject()
'TextBox3.Text = CType(iData.GetData(DataFormats.Text), String)
Your help would be appreciated. Thanks, Sam
Re: Need help with Copy and Paste
If I want to copy something from one textbox to another I generally do something like
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Copy()
TextBox2.Paste()
End Sub
Re: Need help with Copy and Paste
I'm copying and pasting from a web browser to a textbox. I tried TextBox2.Paste(), that didn't work.
Re: Need help with Copy and Paste
If you are doing it like this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Focus()
SendKeys.Send("^{INSERT}")
TextBox3.Text = Clipboard.GetText()
End Sub
Then try this instead:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Focus()
SendKeys.Send("^{INSERT}")
Application.DoEvents()
TextBox3.Text = Clipboard.GetText()
End Sub
Re: Need help with Copy and Paste
Inferrd, You are a genius. Thank you.