Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get something from the clipboard? 2

Status
Not open for further replies.

kruxty

Programmer
Jul 17, 2001
197
PT
I want to make a button to put in a text box the text that it's in the ClipBoard.
How can i do that?
 
Hi,

Try this:

--------------------------------------------------------
Private Sub Command1_Click()
Text1.Text = Clipboard.GetText
End Sub
-------------------------------------------------------

Remember to set the textbox multiline property to true if you want it to show multiple lines.

Sunaj
 
Since the clipboard can contain more than just text, I would change one thing in the code above. You need to check the format type before placing the clipboard data in the text box. Try this . . .

Code:
Private Sub Command1_Click()
  If Clipboard.GetFormat(vbCFText) Then
     Text1.Text = Clipboard.GetText
  end if 
End Sub

- Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top