Team Fly |
Page 23
THIS CHAPTER COVERS VARIOUS techniques that are new in VB.NET and that most programmers need to know about. For example, we must now move to streaming and serialization, capabilities that extend the power of traditional data storage and retrieval, and that address the needs of I/O beyond the local hard drive. These and other important advances are the topic of this chapter.
To retrieve text contents from the Windows Clipboard, you used this code in VB version 6 and earlier:
Text1.Text = Clipboard.GetText
Now in VB.NET you can bring text in from the Clipboard using this code:
Dim txtdata As IDataObject = Clipboard.GetDataObject() ' Check to see if the Clipboard holds text If (txtdata.GetDataPresent(DataFormats.Text)) Then TextBox1.Text = txtdata.GetData(DataFormats.Text).ToString() End If
To export or save the contents of a TextBox to the Clipboard, use this code:
Clipboard.SetDataObject(TextBox1.Text)
Team Fly |