Copy Image in Clipboard and Paste to PictureBox in VB.NET

In this article, we will create a program that copies an image in the clipboard and pastes it to a picturebox. I made a twist here because most programs only copy and pastes a text. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, insert two Buttons for the Copy and Paste Functions named Button1 labeled it as "Copy", and Button2 labeled it as "Paste". Add also two PictureBox named PictureBox1 and PictureBox2 from the toolbox. In the image property of pircturebox1 insert any images on it. You must design your interface like this: design 3. For button1_click as Copy button, put this code below.
  1. My.Computer.Clipboard.SetImage(PictureBox1.Image)
  2. MsgBox("Copied!")
In my previous tutorial, we used the My namespace and same here. My namespace makes the system function easier to locate information and functions of the computer including the clipboard. The clipboard here provides methods to place data from the system Clipboard that we have set the image of Picture1 and will display a message box of "Copied". 4. For button2_click as Paste button, put this code below.
  1. If My.Computer.Clipboard.ContainsImage Then
  2. PictureBox2.Image = My.Computer.Clipboard.GetImage
  3. End If
If the system ClipBoard contains an image on it that we have set earlier in picturebox1, then the copied image on it will be retrieved its image as we have the GetImage method of the clipboard that will be displayed in picturebox2. 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: 09079373999
Telephone: 826-9296

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Add new comment