xxpor Posted June 21, 2004 Share Posted June 21, 2004 For some reason this is not copying to the clipboard, can someone tell be why? Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click Clipboard.SetDataObject(Net.Dns.GetHostByName(Net.Dns.GetHostByName("localhost").HostName).AddressList(0), True) End Sub Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted June 22, 2004 Share Posted June 22, 2004 Does it throw an exception? Or are you unable to get the data back out? I just tried that and it works for me. The Clipboard will store the IPAddress as an IDataObject. You'll have to use the GetDataObject method to get the IDataObject back, then the GetData method from the IDataObject to get the IPAddress, casting appropriately. Link to comment Share on other sites More sharing options...
0 bangbang023 Veteran Posted June 22, 2004 Veteran Share Posted June 22, 2004 is there a "tostring" you can attach to the end of that? Link to comment Share on other sites More sharing options...
0 xxpor Posted June 22, 2004 Author Share Posted June 22, 2004 No I cant pase it in Notepad for example, i dont need to get it back out in my program. And theres no error whatsoever Link to comment Share on other sites More sharing options...
0 xxpor Posted June 22, 2004 Author Share Posted June 22, 2004 I just tryed haveng something on the clipboard, then doing that code, it empties the clipboard, but doesnt put the info on it that i want Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted June 22, 2004 Share Posted June 22, 2004 You need to ToString it: Clipboard.SetDataObject((System.Net.Dns.GetHostByName(System.Net.Dns.GetHostByName("localhost").HostName).AddressList)[0].ToString(), true); I did it in C# though, probably the only difference is the array indexing style. Link to comment Share on other sites More sharing options...
0 xxpor Posted June 22, 2004 Author Share Posted June 22, 2004 w00t that worked thx Link to comment Share on other sites More sharing options...
0 John Veteran Posted June 22, 2004 Veteran Share Posted June 22, 2004 is there a "tostring" you can attach to the end of that? Everything in .NET has a ToString method :yes: At a minimum, it's inherited from System.Object and I believe it returns a string that says what type it is, ie. "System.Object". You can override this in your own classes though to have it return something descriptive to that instance (Y) Link to comment Share on other sites More sharing options...
Question
xxpor
For some reason this is not copying to the clipboard, can someone tell be why?
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Clipboard.SetDataObject(Net.Dns.GetHostByName(Net.Dns.GetHostByName("localhost").HostName).AddressList(0), True)
End Sub
Link to comment
Share on other sites
7 answers to this question
Recommended Posts