Course 2559: Microsoft Training Gets You Going with Visual Basic .NET

By Ian Matthews, MCSE

Published: August 26, 2002 | Updated: July 13, 2007

On This Page
Why Visual Basic .NET?Why Visual Basic .NET?
What you will learnWhat you will learn
Learn about .NET and write codeLearn about .NET and write code
Get behind the user interfaceGet behind the user interface
Take the next stepsTake the next steps
Start building your skills todayStart building your skills today
Additional resourcesAdditional resources

Microsoft Visual Studio .NET is more than just an iteration of the Microsoft flagship programming toolset; it is a completely new software development paradigm. Visual Studio .NET offers developers an integrated program development environment that provides a consistent user interface to .NET. For the first time, developers can build components in any .NET language and use them from any other .NET language.

Visual Studio .NET enables you to create applications for Microsoft Windows, the Web, handheld devices, and other platforms, all with the same set of tools. Furthermore, Visual Studio .NET takes advantage of ADO.NET to provide a complete object model for accessing data and programming tools that streamline the process of writing data access code.

Visual Studio .NET also includes tools for rapid development of server components and middle-tier logic. All these features and more make Visual Studio .NET one of the best tools for both Windows and Web development. From now on and for the foreseeable future, you need .NET programming skills to make it in the Microsoft software development field.

Why Visual Basic .NET?

If you understand programming concepts but are just beginning Windows or Web application development, then learning Visual Basic .NET is a great place to start. The most popular Microsoft programming language, Visual Basic has undergone major changes with .NET; nevertheless, it is still the same rapid application development tool on which millions of programmers depend.

What is your best option for learning Visual Basic .NET? It is Course 2559: Introduction to Visual Basic .NET Programming with Microsoft .NET.

If you are an experienced Visual Basic developer, you should consider instead Course 2373: Programming with Microsoft Visual Basic .NET. And if you are just starting to learn about programming, look for Course 2667: Introduction to Programming.

Top of pageTop of page

What you will learn

Course 2559 targets the beginning developer and starts off Module 1 by introducing Microsoft .NET. Visual Basic .NET is one of four .NET programming languages in Visual Studio .NET; the others are Microsoft Visual C++, Visual C#, and Visual J# .NET. More languages are available from other vendors; more than 20 programming languages have been announced or released for the .NET Framework.

These programming languages have unique characteristics and are suited to different types of application development, but they all are based on the same .NET platform and compile to the same Common Language Runtime. You can build a component in one .NET language and easily access it from another .NET language. This interoperability opens up a whole new world of flexibility in program development.


Top of pageTop of page

Learn about .NET and write code

In Module 1, you will create a simple application in Visual Basic .NET, familiarizing you with the Visual Studio .NET environment, .NET concepts, and the process of creating a new Visual Basic .NET project.

Things get more interesting in Module 2, when you learn to develop a user interface with forms and controls. Forms are the windows that make up your application's interface; controls are the elements that you place on the forms to enable users to interact with your application.

Module 2 is where the "Visual" in Visual Studio comes in: You create your forms and place controls on them simply by dragging icons. The environment automatically writes the code to create these items. Module 2 also teaches the concepts that provide a context for what you are doing, such as classes, objects, properties, methods, and events.

The labs for this part of the course are simple. Lab 1 shows you how to create a simple application that consists of a single form with basic controls. You learn how to create a release build of the application so you can run it outside the Visual Studio environment. In Lab 2, you start developing an application that calculates estimated loan payments. You build the main form, put controls on it, set the control properties, and add an event handler.

Top of pageTop of page

Get behind the user interface

Building a user interface only gets you so far. You still need to tell your application what to do with the user's input. That means you must write your code to attach actions to your interface elements and provide the underlying program logic. Modules 3, 4, and 5 teach basic coding skills:

How to handle data with variables and arrays

How to combine code to build procedures

How to make decisions and repeat steps with conditional statements (If.Then, Select Case) and loops (Do.Loop, For.Next)

Module 6 wraps up the basic content. Your application must verify that the data it receives is appropriate for the intended purpose. Module 6 shows you how to validate user input by restricting the type of data that can be entered, displaying input in particular formats, setting controls on data entry order and other parameters, and prompting users to fix data input errors.

After practice with variables in Lab 3, you build on your loan application in labs 4, 5, and 6 by creating functions to calculate the loan payments and conditionals and by error-checking code to validate the user's input.

Top of pageTop of page

Take the next steps

In Module 7, you learn object-oriented programming concepts, which are centrally important to Visual Basic .NET—the first fully object-oriented version of Visual Basic. Module 7 builds on the introduction to object-oriented computing from Module 2. It shows how classes work and explains abstraction, encapsulation, instantiation, constructors, destructors, and the essential concepts of inheritance, polymorphism, and namespaces.

Your application should gracefully handle unexpected situations such as errors and exceptions. Module 8 introduces debugging with Visual Studio .NET debugging tools, and structured exception handling with the new Try...Catch...Finally statement (see A Sample Lesson: Structured Exception Handling in this article.) In Module 9, you learn more advanced concepts, related to the user interface of your application. Module 9 shows you how to create menus, toolbars, and status bars.

Module 10 introduces you to ASP.NET and shows you how to use Web Forms to create a Web application. This module also introduces XML Web services, showing you how to discover and test available XML Web services, and how to access an XML Web service from an application.

All applications must store data, and most applications you develop will require access to a database. In Visual Basic .NET, you access databases with ADO.NET, which is the topic of Module 11. In this module you learn basic database concepts and how to create, read, update, and delete records in a database by using ADO.NET. In Module 12, you learn how to deploy your application, what assemblies are, and how to create a setup project.

In Lab 7, you practice creating and using your first derived class. In Lab 8, you add Try...Catch...Finally statements to handle exceptions in an existing application, and use Visual Basic .NET debugging tools to debug the application.

In Lab 10, you rebuild your loan payment application as a Web application by placing controls on a Web form and by using an XML Web service to calculate the loan payments. In Lab 11, you learn how to use the Data Form Wizard to pull data from an Access database and display that data on a form, where it can be manipulated. In Lab 12, you complete your loan application by creating a setup project for your application, packaging the application, and then testing and running the installation. Your loan payment application is done.

The following is a sample from the course materials:

A sample lesson: structured exception handling

Structured exception handling is new to Visual Basic .NET and is a radical improvement over previous error-handling techniques. Visual Basic .NET provides the Try...Catch...Finally statement that enables you to package potentially error-causing code together with the appropriate fix or response.

In Course 2559, an exception is defined as any error condition or unexpected behavior that occurs during the execution of a program and requires the execution of code outside the normal flow of control. This means that if something goes wrong, you need special code to handle the exception. When an exception occurs in Visual Basic .NET, the runtime engine creates an Exception object to represent the error. Many Exception subclasses handle the different kinds of errors. Each of these subclasses shares common properties that are derived from the Exception base class, as shown in this table from Course 2559 Student Notes.

PropertyDescription

StackTrace

Lists the called methods that led up to the exception, helping you find where the error is in the code.

Message

Returns a text message describing the error. Use this property to retrieve information about why an exception happened.

You can alter the text to make a cryptic message easier to understand. If you do not supply an error message text string, the default is used.

HelpLink

Gets or sets a link to an associated Help file.

Source

Gets or sets a string containing the name of the object causing the error or the name of the assembly in which the exception originated.

You can take advantage of exceptions by recognizing parts of your code that can cause errors and placing them in a Try...Catch...Finally block so you can handle the errors. The following sample code from Course 2559 Student Notes shows how the Try...Catch...Finally block works.

Try 
   fs = New FileStream("data.txt", FileMode.Open)
Catch
   ex As FileNotFoundException
     MessageBox.Show("Data File Missing")
Catch
   ex As Exception
   MessageBox.Show(ex.Message)
Finally
   If Not (fs Is Nothing) Then fs.Close( )
End Try

You place the potentially troublesome code after the Try statement (in this case: fs = New FileStream("data.txt", FileMode.Open)). Visual Basic .NET then takes any exceptions that happen as a result of this code's execution and passes them through the Catch statements that follow.

Notice that there are two Catch statements in this example. The first exception is a specific kind of exception: File Not Found. If that exception is thrown, Visual Basic .NET displays a message box to the user: Data File Missing. The second exception is general: any other exception that happens is handled here by displaying the default message. You can choose whether or not to include a Finally statement. In this block, you place any code that you want to execute regardless of whether an exception occurs—for example, code that closes a file or releases an object. In this way, all exceptions are handled: The code under Try always runs; the appropriate Catch statement is executed if an exception happens; and the code under Finally, if you include this section, always executes last.

Notice how the Catch statements are constructed. When an exception is thrown, Visual Basic .NET runs down the list of Catch statements and executes the first one that matches the exception in question. For that reason, always place in the appropriate order any specific exceptions that you want to be handled. Then, the last Catch statement handles the general case, so all exceptions are handled by default. Visual Basic .NET does not force you to construct your Catch statements in this way, but doing so is considered a best practice.

Top of pageTop of page

Start building your skills today

Course 2559: Introduction to Visual Basic .NET Programming with Microsoft .NET begins your training to become a professional developer who builds .NET applications with Visual Basic .NET. This course has been designed by experienced developers, many of whom are also Microsoft Certified Trainers (MCTs). Their experiences from the classroom are reflected in the course content level and flow. Every lab is designed to provide hands-on practice with realistic examples that apply the techniques and technology you are learning.

After taking this course, you will:

Understand how Visual Basic .NET enables you to create leading-edge .NET applications by using XML Web services and ADO.NET.

Learn how to code in Visual Basic .NET, and how to use Visual Studio .NET, the .NET Framework, and the .NET development paradigm.

Acquire the programming skills that will prepare you for other Microsoft courses, which in turn will help you to earn the Microsoft Certified Application Developer (MCAD) certification.

Course 2559 and other Official Microsoft Learning Products courseware is available through Microsoft Certified Partner(s) for Learning Solutions programs. These courses are taught by MCTs who have achieved the premier Microsoft credentials. In addition, Microsoft Certified Partner(s) for Learning Solutions programs offer state-of-the-art facilities and are required by Microsoft to meet certain criteria before they can deliver Official Microsoft Learning Products courseware.

Top of pageTop of page

Additional resources


Top of pageTop of page