Home > Microsoft .Net Development Tips > Visual Basic and Visual Basic .NET > 'My' extensions turbocharge new VB tool set
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

VISUAL BASIC AND VISUAL BASIC .NET

'My' extensions turbocharge new VB tool set


Ed Tittel
11.01.2005
Rating: --- (out of 5)


.NET Essentials Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


My.Settings is a very useful new aspect of the .NET Framework 2.0. It is worthwhile to view this element of the My extensions in context, along with its other brethren. In fact, if there's an underappreciated workhorse in the new Visual Studio 2005 (and its equally new companion, the .NET Framework 2.0) it's got to be the many Visual Basic language extensions that fall under the My hierarchy in that environment. You can use My constructs for an amazing array of activities, as you'll shortly see.

A brief run-down on what this do-it-all namespace can do includes the following:

  • Supports advanced IDE features such as Edit and Continue, IntelliSense code snippets, and the Exception Assistant;
  • Supports advanced language enhancements such as generics, partial classes, and unsigned types; and
  • Works with .NET Framework enhancements to Windows Forms, data binding, and ClickOnce deployment, among others.

    A good example of what's possible may be revealed by exploring the My.Computer.FileSystem and other related classes, which some experts describe as a "speed-dial" for the .NET framework. For example, whereas some programmers may choose to use IO.StreamReader and its sr.ReadToEnd function to copy the contents of a text file into a string (which requires at least three lines of code), a single assignment statement using My will also do the job -- namely:

    Contents = My.Computer.FileSystem.ReadAllText("c:\mytextfile.txt")
    

    Understanding the basic organization of classes within My really helps to get a sense of the kinds of uses to which these language extensions are suited:

  • My.Application: This offers information about application information and services available, including a built-in logging facility.
  • My.Computer: Along with My.User, this permits easy navigation of services and data for the current host computer (this is where the FileSystem classes come into play, and where My.Computer.Ports, My.Computer.Network, and My.Computer.Printer are also available).
  • My.Forms: Use this to navigate and interact with forms available to your project.
  • My.Resources: Use this to inspect or interact with resources configured using other VB or VS.NET tools in advance, or added to your project.
  • My.Settings: Use this to inspect or interact with settings configured using other VB or VS.NET tools in advance, or added to your project.
  • My.User: Along with My.Computer, this permits easy navigation of services and data for the current host computer.
  • My.WebServices: Use this to navigate and interact with Web services referenced in a project.

    There's so much going on here that it will take some time to explore and learn the many capabilities (and time-saving techniques) available through My. You'll also find these MSDN articles helpful in that quest:

  • Visual Basic Developer Center Navigate the .NET Framework and Your Projects with "My" by Duncan Mackenzie.
  • Visual Studio 2005 Technical Articles My.Internals: Examining the Visual Basic My Feature

    But if you put in the time and effort, you can count on reaping some righteous rewards!


    Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed at etittel@techtarget.com with comments, questions, or suggested topics or tools to review.


    Rate this Tip
    To rate tips, you must be a member of SearchWinDevelopment.com.
    Register now to start rating these tips. Log in if you are already a member.




    Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



    RELATED CONTENT
    Visual Basic and Visual Basic .NET
    Compose XML more quickly using Visual Basic 9
    Virtualization keeps Legacy Apps alive
    VB 9 Anonymous Types help create flexible objects
    Visual Studio Team System Add-ins: Conchango Scrum for Team System and Scrum Dashboard
    Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
    Check out CodePlex for a ton of interesting .NET projects
    Book excerpt: Murach's VB 2008
    Book excerpt: Printing in Visual Basic 2005
    Visual Basic 2008 and closures
    WinForms development using SQL Server 2005 and Visual Basic 2005

    .NET Framework 2.0 and Visual Studio 2005 development
    Mono 2.0 moves .NET apps to Linux - includes migration analyzer
    Using the Visual Studio 2005 DataSet Designer to build a data access layer
    SCM Visual Studio plug-in offers updated interface
    Assembly versioning in the .NET Framework 2.0
    SearchVB.com's Podcast Page
    Visual Studio 2008 Learning Guide: Multi-targeting
    On managing a .NET Framework 1.x migration
    Case Study: IdeaBlade DevForce object mapping
    Book excerpt: Printing in Visual Basic 2005
    CodeGear RAD Studio now supports .NET 2.0

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    IronRuby  (SearchWinDevelopment.com)

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary

    DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



  • Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




    All Rights Reserved, Copyright 2000 - 2009, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts