Chapter 2 New Ways of Doing Traditional Jobs

Team Fly 

Page 23

Chapter 2
New Ways of Doing Traditional Jobs

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.

Clipboard Access

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 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net