VB6 Tutorial 68: Using the Clipboard

By | 2018-06-10

Clipboard object is a simple object in Visual Basic 6 that stores data. You can retrieve the data from the clipboard using appropriate methods of the clipboard object.

In the Windows operating system, when you copy some data, the data is automatically copied or stored in the clipboard object. You can place data in the clipboard object and retrieve the data from clipboard.

You can easily copy and paste data among applications – from one application to another using the clipboard object. The clipboard object has no properties. It has a few methods that help you work upon the data.

The SetText method

The SetText method puts text in the clipboard. In other words, you can place text in the clipboard object using this method.

Example

Clipboard.SetText Text1.Text

The Clear method

The Clear method clears the clipboard.

Example

Clipboard.Clear

The GetText method

The GetTex method lets you retrieve the text which is in clipboard.

Example

Text2.Text = Clipboard.GetText

The SetData method

The SetData method places data e.g an image in clipboard.

Example

Clipboard.SetData Picture1.Picture
' or
Clipboard.SetData LoadPicture("d:\mypic.bmp")

The GetData method

The GetData method retrieves data, for example an image, from the clipboard object.

Example

Picture2.Picture = Clipboard.GetData

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.