Get Clipboard Text - Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

Sometimes there is a need to get the text stored in the clipboard. The clipboard as you probably know is the area in the computer where all things gets stored into when a user perform a copy or cut operation.
You probably do this operation many times a day. Whether you copy an address from a site, or an image from a file, they all get stored in the clipboard for later use. You access the clipboard when you click the paste command.

In Visual Basic, it is very easy to get that text stored in the clipboard and paste it into a textbox or a string variable.

The following code is used to get the text from the clipboard and inserts it into a textbox:

If My.Computer.Clipboard.ContainsText Then
TextBox1.Text = My.Computer.Clipboard.GetText
End If

You can add the above code to a button click event, or any triggered event.

Share This

Home | About | Contact | Privacy Policy

Copyright 2018 - All Rights Reserved.