Copy and Paste in VB6

In this article, we will create a program that has a copy and paste functions of any Text Documents. Copy and Paste Functions are the most widely used in making an encoding or typing faster. Now, let's start this tutorial! 1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open. 2.Go to Project Tab, and Click Components or Press Ctrl+T. 3.In the Controls Tab, find and check Microsoft Rich TextBox Control 6.0. Click apply and then click OK. 4.Next, insert two Buttons for the Copy and Paste Functions named Command1 labeled it as "Copy", and Command2 labeled it as "Paste". Add also RichTextBox namedRich TextBox1 from the component. You must design your interface like this: design 5.Now put this code for your code module.
  1. Private Sub Command1_Click()
  2. Clipboard.SetText (RichTextBox1.Text)
  3. MsgBox "Copied!"
  4. End Sub
  6. Private Sub Command2_Click()
  7. If Clipboard.GetFormat(vbCFText) And Not Clipboard.GetFormat(vbCFRTF) Then
  8. RichTextBox1.SelText = Clipboard.GetText(vbCFText)
  9. RichTextBox1.SetFocus
  10. End If
  11. End Sub


In our Button1 that has the Copy Function, we used the Clipboard statement. Clipboard control - -- . SetText property from the clipboard means to have the clipboard set a text out of the string inputted in our RichTextBox. For Button2 that has the Paste Function, we have created an IF Statement that if the clipboard has a Copied From Text (vbCFText) and not a format of Copied From RTF file (vbCFRTF) then our RichTextBox will have its content coming from the ClipBoard that we set earlier, that is to get the text out of the clipboard when have clicked the copy button. Then after pasting the content of the clipboard from RichTextBox it will focus on the word/s that has copied.


outputoutput Download the source code below and try it! :) For more inquiries just contact my number or e-mail below. Best Regards, Engr. Lyndon R. Bermoy IT Instructor/System Developer/Android Developer Mobile: 09488225971 Telephone: 826-9296 Follow and add me in my Facebook Account: Visit and like my page on Facebook at:

Add new comment