Visual Basic.NET
  Home arrow Visual Basic.NET arrow Write Readable Code and Comments for Windo...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC.NET

Write Readable Code and Comments for Windows Forms Applications
By: Murach Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2009-07-09

    Table of Contents:
  • Write Readable Code and Comments for Windows Forms Applications
  • The event handlers for the Invoice Total form
  • How to code with a readable style
  • How to code comments

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Write Readable Code and Comments for Windows Forms Applications


    (Page 1 of 4 )

    In this second part of a five-part series that shows you how to code and test a Windows Forms application, you will learn (among other things) how to make sure your code and comments are clear and readable. This will simplify the debugging process and in general make code maintenance much easier. This article is excerpted from chapter 3 of Murach's Visual Basic 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774456).

    How IntelliSense helps you enter the code for a form

    In figure 3-2, you saw how IntelliSense displays a list of the available members for a class or an object. IntelliSense can also help you select a type for the variables you declare, which you’ll learn how to do in chapter 4. And it can help you use the correct syntax to call a procedure as shown in chapter 6 or to call a method as shown in chapter 11.

    With Visual Basic 2008, IntelliSense has been improved to help you even more as you enter the basic code for an application. In particular, IntelliSense can help you enter statements and functions as well as the names of variables, objects, and classes. Figure 3-5 illustrates how this works.

    The first example in this figure shows the list that IntelliSense displays when you start to enter a new line of code. Here, because I entered the letter d, the list includes only those items that start with that letter. As described earlier in this chapter, you can enter as many letters as you want, and Visual Studio will continue to filter the list so it contains only the items that begin with those letters. You can also scroll through the list to select an item, and you can press the Tab or Enter key to insert the item into your code.

    Note that when you select a keyword that begins a statement, a description of the statement is displayed in a tool tip along with the syntax of the statement. That can help you enter the statement correctly. In addition, as you enter the statement, you’re prompted for any additional keywords that are required by the statement.

    The second example in this figure shows the list that’s displayed as you enter the code for an If statement. You’ll learn more about this statement in chapter 5. For now, just notice that after I typed a space and the letter t following the If keyword, Visual Studio displayed a list of all the items that begin with the letter T. That made it easy to select the item I wanted, which in this case was the name of a control.

    If you’ve used previous versions of Visual Basic, you’ll appreciate these expanded IntelliSense features. For example, it’s easy to forget the exact syntax of a statement or function, so the tool tip that’s displayed when you select a statement or function can help refresh your memory. Similarly, it’s easy to forget the names you’ve given to items such as controls and variables, so the list that’s displayed can help you locate the appropriate name. And that can help you avoid introducing errors into your code.

    Although it’s not shown here, Visual Basic 2008 IntelliSense also lets you see the code that’s behind a list while the list is still displayed. To do that, you simply press the Ctrl key and the list becomes semi-transparent. This eliminates the frustration a lot of programmers felt when code was hidden by an IntelliSense list in previous versions of Visual Studio.

    The list that’s displayed when you enter a letter at the beginning of a line of code

    The list that’s displayed as you enter code within a statement

    Description

    1. The IntelliSense that’s provided for Visual Basic 2008 lists keywords, functions, variables, objects, and classes as you type so you can enter them correctly.
    2. When you highlight an item in a list, a tool tip is displayed with information about the item. 
       
    3. If you need to see the code behind a list without closing the list, press the Ctrl key. Then, the list becomes semi-transparent.

    Figure 3-5.   How IntelliSense helps you enter the code for a form

    More Visual Basic.NET Articles
    More By Murach Publishing


     

    Buy this book now. This article is excerpted from chapter three of Murach's Visual Basic 2008, written by Anne Boehm (Murach, 2008; ISBN: 1890774456). Check it out today at your favorite bookstore. Buy this book now.

    VISUAL BASIC.NET ARTICLES

    - User-defined Functions using Visual Basic Ap...
    - Understanding Object Binding in VBA
    - Mastering the Message Box
    - Testing a Windows Forms Application
    - Using Visual Basic.NET Features to Code a Wi...
    - Correcting Code in a Windows Forms Applicati...
    - Write Readable Code and Comments for Windows...
    - How to Code and Test a Windows Forms Applica...
    - Adding Features to a Windows Forms Applicati...
    - How to Design a Windows Forms Application
    - LINQ to XML Programming Using Visual Basic.N...
    - Understanding Delegates using Visual Basic.N...
    - Create a Sudoku Puzzle Generator using VB.NET
    - Entity Creation and Messaging in a VB.NET Te...
    - Movement and Player Statistics in a VB.NET T...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek