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:
5.Now put this code for your code module.
Private Sub Command1_Click()
Private Sub Command2_Click()
If Clipboard.GetFormat(vbCFText) And Not Clipboard.GetFormat(vbCFRTF) Then
RichTextBox1.SelText = Clipboard.GetText(vbCFText)
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.
Download the source code below and try it! :)
For more inquiries just contact my number or e-mail below.
Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Follow and add me in my Facebook Account: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware