Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

What's New in Visual Basic 2005? : Page 4

Going forward, Microsoft will make a big push to migrate Visual Basic 6 developers to Visual Studio 2005. The Visual Basic team has addressed many of the areas that caused VB6 developers to hold on to their old code base.


advertisement
XML Code Commenting
XML code commenting was long supported in languages like C# and Java, and it is finally supported in this new release of Visual Basic.
 
Figure 7. XML Comments: The figure shows inserted XML comments.
XML code commenting allows you to use XML elements to document your code. To insert an XML comment, simply type three apostrophes before a class or method definition and the XML code templates will automatically be inserted for you (see Figure 7).

Once you have documented your code with XML elements, an XML document containing all the comments in your code would be generated when you build your application. This XML document could then be processed by a third-party tool so that a help file may be generated. NDoc is one such tool that helps to generate documentations for .NET assemblies. For a detailed look at how to use NDoc to generate professional-looking documentation, checkout my MSDN article, "Generating Documentation for Your Visual Basic .NET Applications". Editor Improvements
Besides the language innovations, the code editor in Visual Studio 2005 is also significantly improved to simplify Visual Basic development.

 
Figure 8. Autocorrect: The figure shows how Autocorrect suggests remedies for an error.
Autocorrect
In Visual Studio .NET 2003, if a statement contains an error, the offending keyword within that statement would be highlighted, together with the reason for the error. In Visual Studio 2005, Microsoft has gone one step further with the Autocorrect feature. The Autocorrect feature tries to analyze the cause of the error and make suggestions. For example, you may have remembered to add a reference to the System.Data.dll for ADO.NET data access in your project, but have forgotten to import the System.Data namespace. In this case, if you try to declare a SqlDataReader variable, Visual Basic will flag the SqlDataReader class as not defined. Using Autocorrect, you can place your cursor over the underline and click the exclamation icon in red to view a list of suggested remedies (see Figure 8).


 
Figure 9. Exception Assistant: The figure shows the Exception Assistant in action.
In this case, you can either use a fully qualified name for the SqlDataReader class, or simply add an imports statement at the top of the code. Exception Assistant
Another improvement in Visual Studio is the new Exception Assistant. The Exception Assistant will kick into action when a runtime error occurs. For example, in Figure 9 I have forgotten to add the New keyword to the instantiation statement, and using the Button object without instantiation will cause a runtime error. While this is a common error, it may take a Visual Studio .NET beginner a while to figure it out. The Exception Assistant tries to suggest ways to remedy the runtime error.



Wei-Meng Lee is a Microsoft MVP and founder of Developer Learning Solutions, a technology company specializing in hands-on training on the latest Microsoft technologies. He is an established developer and trainer specializing in .NET and wireless technologies. Wei-Meng speaks regularly at international conferences and has authored and coauthored numerous books on .NET, XML, and wireless technologies. He writes extensively on topics ranging from .NET to Mac OS X. He is also the author of the .NET Compact Framework Pocket Guide, ASP.NET 2.0: A Developer's Notebook (both from O'Reilly Media, Inc.), and Programming Sudoku (Apress). Here is Wei-Meng's blog.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap