.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to clear paste clip board using VB.net

3 REPLIES 3
Reply
Message 1 of 4
masihuzzaman
5078 Views, 3 Replies

How to clear paste clip board using VB.net

We are having a problem related to paste clipboard. We are extracting block attribute to MS access file using VB.net.
While extracting block data, all block object in paste clipboard is also exported to MS access file. Kindly guide to clear paste clip board using VB.net before exporting block attribute data. We want to extract block object existing in drawing only. Thanks in advance.

3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: masihuzzaman

Could you explain in detail how the block data is extracted and showing the code of doing it? Saving data into a database, be it is MS Access, or other types of database, is a fairly common task doing by code. I cannot see why clip board is involved, or needed.

Message 3 of 4
hgasty1001
in reply to: masihuzzaman

Hi,

 

Clipboard is a class of System.Windows... so yo can call ClipBoard.Clear or any other method: ClipBoard Class

 

Gaston Nunez

 

 

 

 

Message 4 of 4
Hallex
in reply to: masihuzzaman

Here is working code from one of winform application

The last part of code is borrowed from MSDN article,

change full path of ms access file and table name:

    Public Shared Sub TestMSAcessToClipboard()
        Dim conn As New System.Data.OleDb.OleDbConnection()
        conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + "C:\Test\MyBlocks.accdb" + ";Jet OLEDB:Database Password=;"
        conn.Open()
        Dim dt As New System.Data.DataTable()
        Dim oleCmd As New System.Data.OleDb.OleDbCommand("SELECT * From [" + "MyBlocks" + "]", conn)
        Using oleRead As System.Data.OleDb.OleDbDataReader = oleCmd.ExecuteReader()

            dt.Load(oleRead)
            oleRead.Close()
        End Using

        Dim rows As System.Data.DataRow() = dt.Select()
        conn.Close()
        Dim sb As New StringBuilder()
        For Each row As System.Data.DataRow In rows
            Dim str As String = String.Empty
            For col As Integer = 0 To row.ItemArray.Length - 1
                str = str & row(col).ToString() & vbTab
            Next
            sb.AppendLine(str)
        Next

        Dim stack As Boolean = True

        Dim data As New DataObject(DirectCast(sb.ToString(), Object))
        If stack Then
            ' Place the persisted data on the clipboard.
            Clipboard.SetDataObject(data, True)
        Else
            ' Place the non-persisted data on the clipboard.
            Clipboard.SetDataObject(data, False)
        End If
        MessageBox.Show("Paste this data to text or csv file")
    End Sub

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost