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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Let me first say that I used to lov

Status
Not open for further replies.

VBMental

Programmer
Feb 26, 2002
14
0
0
US
Let me first say that I used to love VB.
With that said, let me say that I kind of dislike .NET.
Firstly I hate the fact that you have to deploy the whole .NET framework. I think it's way too much overhead, and YES I understand that it has a lot of useful objects but undoubtedly it slows down the machine and certain aspects of programming the .NET framework are extremely abstract and not very well documented.

Ok, that was just my opinion- here is my most recent problem.

In trying to use the clipboard object in VB, I keep getting a value of nothing from the GetData method of the clipboard whenever I set it to an instance of an object other than text.

Here's an example:
(Assuming I want to copy the contents of the listbox: List1)

Private Sub btnCopy_Click(....)
'To copy the listbox items
Clipboard.SetDataObject(cmb1.Items)
btnPaste.Enabled = True
End Sub

Private Sub btnPaste_Click(...)
' to paste the listbox items
Dim Data As IDataObject = Clipboard.GetDataObject
Dim C As ComboBox.ObjectCollection = Data.GetData(GetType(ComboBox.ObjectCollection))
Dim O as object
'The next line causes the NullReference error
For Each O in C
...
Next

End Sub
 
Possibly your Data.GetData statement is failing. You could try

Dim C as Object = Data.GetData(DirectCast(cmb1.Items, String)

You might take a look at what is on the Clipboard to make sure that your

Dim data As IDataObject = Clipboard.GetDataObject()
Dim sFormats() As String = data.GetFormats()
Dim i As Integer
Dim s as String = ""

For i = 0 To sFormats.GetUpperBound(0)
Dim objClip As Object = data.GetData(sFormats(i))
s &= objClip.GetType().ToString() & VBCRLF
Next
MessageBox.Show(s)
Dean
---
goddette@san.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top