Accessing Text in the Clipboard
Visual Basic has provided the Clipboard object to access the contents of the clipboard with ease.
To retrieve the text from the clipboard, use the instructions:
Clipboard.GetText |
Example:
Dim S As String |
While to insert text into the clipboard, can be used the following instructions:
Clipboard.Clear |
Example:
Dim S As String |
Accessing Images in the Clipboard
To retrieve the data in the form of a picture (bitmap) from the clipboard, use the following instructions:
Clipboard.GetData(vbCFBitmap) |
Example:
Create a PictureBox control (Picture1) and CommandButton (Command1) to the Form.
'*** codes for Command1 |
Note: Before you click the Command1 button, do PrintScreen first (press the PrintScreen button on your keyboard). Printscreen image will be displayed on top of Picture1 control.
--------------
To insert the image-formatted data into the clipboard, use these instructions:
Clipboard.Clear object of IPictureDisp |
Example:
Here we will insert an image that already exist in the PictureBox to the clipboard.
Create a PictureBox control (Picture1) and CommandButton (Command1) to the Form. Insert any image through the Picture property of Picture1.
'*** codes for Command1 |
Note: To test the example above, after you click the Command1 button, open the Paint program of Windows, and Paste (CTRL + V). If the image in Picture1 appears on the Paint program, means the examples above work. I myself have tried it and succeeded.
No comments:
Post a Comment