Results 1 to 5 of 5

Thread: Need help with Copy and Paste

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         TextBox1.Copy()
    3.         TextBox2.Paste()
    4. End Sub

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    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.

  4. #4
    Frenzied Member
    Join Date
    Jul 2011
    Location
    UK
    Posts
    1,335

    Re: Need help with Copy and Paste

    If you are doing it like this:
    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     WebBrowser1.Focus()
    3.     SendKeys.Send("^{INSERT}")
    4.     TextBox3.Text = Clipboard.GetText()
    5.  
    6.     End Sub
    Then try this instead:
    vb Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     WebBrowser1.Focus()
    3.     SendKeys.Send("^{INSERT}")
    4.  
    5.     Application.DoEvents()
    6.  
    7.     TextBox3.Text = Clipboard.GetText()
    8.  
    9.     End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2011
    Posts
    184

    Re: Need help with Copy and Paste

    Inferrd, You are a genius. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width