Quick Visual Studio .NET Tips

Still getting used to Visual Studio .NET? Here are a handful of little-known Visual Studio tips sure to make your life easier...

Writing a Developer TODO: List

The Task window in VB.NET is a great way of keeping track of tasks that are related to your project. For example, if you have code issues or compile errors, VB.NET will automatically list them here.

You also can add your own comments to the Task list, with the TODO keyword. To use this feature, simply add a comment to your code that starts with the TODO keyword. It will automatically be added to your existing Task list. For example:

' TODO: Rewrite function so works with .DOC files

To view the Task list, select View > Other Windows > Task List from the menu, or press Ctrl+Alt+K. The Task list often filters its contents, so it displays only certain information. To view everything, right-click on your list and select All Tasks > All.

Top Tip: Fed up with the TODO keyword? Users of Visual Studio .NET 2003 (Everett) have automatic support for the "HACK" prefix, which works in the exact same way as TODO, yet attracts much more kudos. You can edit the Task list keywords yourself by editing the values in Tools > Options > Environment > Task List.



Click here for a larger image.

Figure: If only all TODO lists were this short...

Storing Often-Used Code in the Toolbox

There's an easy way to store often-used code and templates in VS .NET. Simply drag and drop your code straight onto one of the toolbox tabs, such as the General tab. When you need to use it again, simply drag and drop back into your code window. And, best of all, these snippets persist from project to project, saving even more development time.



Click here for a larger image.

Figure: Adding code to the toolbox

Organizing your Project with Folders

Overwhelmed with the number of files that now make up your application? Starting to lose track of which .VB files do what? Well, there's a simple method of keeping track. Use folders!

Right-click on your project in the Solution Explorer and select Add > New Folder. Then, simply drag-and-drop your existing code files into the new folders. For example, you may have one folder called "User Interface" to store your forms. Or a folder called "Database Code" to store your data access classes.

Don't worry: there's no extra configuration required; your entire project compiles as normal with no extra effort. It simply allows you to organize your project the way it should be.

A simple tip, but one that can turn chaos into control within minutes.

Figure: One of my company C# projects, really taking advantage of folders

Discovering Whether You're Running in the IDE

Previous versions of Visual Basic made it easy to figure out whether you were running your application through the IDE (Integrated Development Environment). It simply allowed you to check which "mode" your application was in. VB .NET, however, isn't quite as easy-going.

The most common method of figuring out whether the application is running in the .NET IDE is to check the System.Diagnostics.Debugger.IsAttached property to determine whether a debugger is attached to the currently executing code. If so, you can safely assume your code is running from within the IDE.

If you're designing your own controls, you might also run into the situation where your code is running in design modewhile you only want it to execute during 'full' runtime. In this situation, simply check the DesignMode property of your component (that is, from inside your control: Me.DesignMode). If it returns True, you're running in the IDEb—so cut your code short.

A simple solution to a common question, and definitely worth remembering.

# # #



About the Author

Karl Moore

Karl Moore (MCSD, MVP) is an experience author living in Yorkshire, England. He is the author of numerous technology books, including the new Ultimate VB .NET and ASP.NET Code Book (ISBN 1-59059-106-2), plus regularly features at industry conferences and on BBC radio. Moore also runs his own creative consultancy, White Cliff Computing Ltd. Visit his official Web site at www.karlmoore.com.

Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Hybrid cloud platforms need to think in terms of sweet spots when it comes to application platform interface (API) integration. Cloud Velocity has taken a unique approach to tight integration with the API sweet spot; enough to support the agility of physical and virtual apps, including multi-tier environments and databases, while reducing capital and operating costs. Read this case study to learn how a global-level Fortune 1000 company was able to deploy an entire 6+ TB Oracle eCommerce stack in Amazon Web …

  • Live Event Date: August 19, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT You deployed your app with the Bluemix PaaS and it's gaining some serious traction, so it's time to make some tweaks. Did you design your application in a way that it can scale in the cloud? Were you even thinking about the cloud when you built the app? If not, chances are your app is going to break. Check out this upcoming webcast to learn various techniques for designing applications that will scale successfully in Bluemix, for the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds