The My Namespace


Visual Basic 2005 includes a new "My" top-level namespace, which Microsoft is touting as one of the big new convenience features that will draw holdout Visual Basic 6.0 stalwarts into the .NET fold. But most of it is really not that dramatic. My collects commonly used features that are currently sprinkled around the FCL, and puts them in a mini-hierarchy for convenient access. It's really not much more complicated than that. The hierarchy is nicely organized, with sections for user, application, and computer-specific information. It's used just like any other part of the framework, although you cannot use the Imports keyword to access its components by a relative path.

Overall, My is very easy to use. To display the version number of your application, for instance, use the following statement.

MsgBox(My.Application.Info.Version.ToString) 


Some areas of the My namespace are dynamic; classes are added or removed as you modify your source code. In Windows Forms applications, the My.Forms branch includes entries for each one of the project's forms. As you add new forms, new entries are added automatically. The My.Forms object then makes a reference to each form available for use in your code.

My.Forms.Form1.Text = "Welcome" 





Start-to-Finish Visual Basic 2005. Learn Visual Basic 2005 as You Design and Develop a Complete Application
Start-to-Finish Visual Basic 2005: Learn Visual Basic 2005 as You Design and Develop a Complete Application
ISBN: 0321398009
EAN: 2147483647
Year: 2006
Pages: 247
Authors: Tim Patrick

Similar book on Amazon

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