Results 1 to 5 of 5

Thread: Copy & Paste!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2000
    Location
    staffs
    Posts
    2

    Angry

    I Have been trying for ages to get a copy and paste function to work in my application, but I just cant figure out how to do it! All I want to do is highlight something in one of my text boxes, go to the edit menu, click on copy and then paste the data into a new text box using the edit menu, but its proving very annoying and difficult. Can any of you help me??

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    736
    Hi. I experimented with this for a few minutes and the following will allow you to copy text from one textbox to the clipboard and then paste that text into another textbox. The Clipboard object is shared by all Windows applications, so no need to declare it in VB.

    Code:
    Option Explicit
    
    Private Sub CmdCopy_Click()
        Clipboard.Clear
        Clipboard.SetText (Text1.SelText)
    End Sub
    
    Private Sub CmdPaste_Click()
        Text2 = Clipboard.GetText
    End Sub
    Maybe it will give you a starting point to work from.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'From textbox to textbox you don't need copy 'n' paste
    Code:
    Private Sub Command1_Click()
    'paste it at the end of text2.text
    'could be anywhere you want or overwrite
       Text2.SelStart = Len(Text2.Text)
       Text2.Text = Text2.Text & " " & Text1.SelText
    End Sub
    
    Private Sub Form_Load()
        Text1.Text = "Mary Lou"
        Text2.Text = "Hello"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    New Member
    Join Date
    Oct 1999
    Posts
    14

    Try This

    Put a menu up (Edit) subitems Copy, Paste
    Place two textboxes on form

    Private Sub mCopy_Click()

    If Me.ActiveControl.Name Like "Text*" Then
    Clipboard.Clear
    Clipboard.SetText Me.ActiveControl.Text
    End If

    End Sub

    Private Sub mPaste_Click()

    If Me.ActiveControl.Name Like "Text*" Then
    Me.ActiveControl.Text = Clipboard.GetText
    End If

    End Sub

  5. #5
    Guest
    You should check to see if text is highlighted as well.

    Code:
    Private Sub CmdCopy_Click()
        If Text1.SelText <> "" Then
             Clipboard.Clear
             Clipboard.SetText (Text1.SelText)
        End If
    End Sub
    But as Wayne (HeSaidJoe) said, you don't need copy and paste to put something from one textbox to the other.

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