get saved clipboard information

Johnson

Well-known member
Joined
Mar 6, 2009
Messages
158
Programming Experience
Beginner
How do i save information thats stored in the clipboard to a varible?
 
That was a very confusing way for me. alot of code

i found a very simple way

VB.NET:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text)) Then
            TextBox1.Text = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString()
        Else
            TextBox1.Text = "The clipboad does not contain any text"
        End If
    End Sub

thanks john
 
If you only want text content there is simpler ways:
VB.NET:
If Clipboard.ContainsText Then
    Me.TextBox1.Text = Clipboard.GetText
End If
Similar for various formats you don't need to first get the DataObject, then get specific. Clipboard class has both a ContainsData and a GetData method.
 
Back
Top