Visual Basic.NET Tutorial - Learn VB 2008 Programming

Jump to Chapter Contents

Welcome to Visual Basic.NET 2008, one of the most latest and mature version yet of the most popular programming language for building Windows and web applications. In modern software development, however, the language is only one of the components we use to build applications. The most important component is the .NET Framework, which is an indispensable component of every application; it’s actually more important than the language itself. You can think of the Framework as an enormous collection of functions for just about any programming task. All drawing methods, for example, are part of the System.Drawing class. To draw a rectangle, you call the DrawRectangle method of the System.Drawing class, passing the appropriate arguments. To create a new folder, you call the CreateDirectory method of the Directory class, and to retrieve the files in a folder you call the GetFiles method of the same class.

The Framework contains all the functionality of the operating system and makes it available to your application throughmethods. The language and the Framework are the two "programming" components, absolutely necessary to build Windows applications. It’s possible to develop applications with these two components alone, but the process would be awfully slow. The software development process relies on numerous tools that streamline the coding experience, and these tools are provided for us by Visual Studio 2008.

The third component is an integrated environment that hosts a number of tools enabling you to perform many common tasks with point-and-click operations. It’s basically an environment in which you can design your forms with visual tools and write code as well. This environment, provided by Visual Studio 2008, is known as an integrated development environment, or IDE. You’ll be amazed by the functionality provided by the tools of Visual Studio 2008: you can actually design a functional data-driven application without writing a single line of code. You can use similar tools in the same environment to design a fancy data-driven web page without a single line of code. Visual Studio even provides tools for manipulating databases and allows you to switch between tasks, all in the same, streamlined environment. You realize, of course, that Visual Studio isn’t about writing applications without code; it just simplifies certain tasks through wizards and, more often than not, we step in and provide custom code to write a functional application. Even so, Visual Studio 2008 provides numerous tools, from debugging tools to help you track and fix all kinds of bugs in your code, to database manipulation tools.

This tutorial shows you how to use Visual Studio 2008 and Visual Basic 2008 to design rich Windows and web applications. We’ll start with the visual tools and then we’ll explore Visual Basic and the Framework. AWindows application consists of a visual interface and code behind the elements of the interface. (The code handles the user actions on the visual interface, such as the click of a button, the selection of a menu item, and so on.) You’ll use the tools of Visual Studio to build the visual interface and then you’ll program the elements of the application with Visual Basic. For any nontrivial processing, such as file and folder manipulation, data storage, and so on, you’ll use the appropriate classes of the .NET Framework. A substantial segment of this tutorial deals with the most useful components of the Framework.

You don’t need a solid knowledge of Visual Basic to read this tutorial, but you do need a basic understanding of programming. You need to know the meaning of variables and functions and how an If. . .Then structure works. This tutorial is aimed at the typical programmer who wants to get the most out of Visual Basic. It covers the topics I felt are of use to most VB programmers, and it does so in depth. Visual Basic 2008 and the .NET Framework 3.5 are two extremely rich programming tools, and I had to choose between a superficial coverage of many topics and an in-depth coverage of fewer topics. To make room for more topics, I have avoided including a lot of reference material and lengthy listings. For example, you won’t find complete project listings or form descriptions. I assume that you can draw a few controls on a form and set their properties, and that you don’t need long descriptions of the controls’ properties. I’m also assuming that you don’t want to read the trivial segments of each application. Instead, the listings concentrate on the ‘‘meaty’’ part of the code: the procedures that explain the topic at hand.

The topics covered in this tutorial were chosen to provide a solid understanding of the principles and techniques for developing applications with Visual Basic. Programming isn’t about new keywords and functions. I chose the topics I felt every programmer should learn in order to master the language. I was also motivated by my desire to present useful, practical examples. You will not find all topics equally interesting or important. My hope is that everyone will find something interesting and something of value for his or her daily work— whether it’s an application that maps the folders and files of a drive to a TreeView control, an application that prints tabular data, a data-driven application for editing customers or products, or an application that saves a collection of objects to a file.

Many tutorials offer their readers long, numbered sequences of steps to accomplish a task. Following instructions simplifies certain tasks, but programming isn’t about following instructions. It’s about being creative; it’s about understanding principles and being able to apply the same techniques in several practical situations. And the way to creatively exploit the power of a language such as Visual Basic 2008 is to understand its principles and its programming model. In many cases, I provide a detailed, step-by-step procedure that will help you accomplish a task, such as designing a menu, for example. But not all tasks are as simple as designing menus. I explain why things must be done in a certain way, and I present alternatives and try to connect new topics to those explained earlier in the tutorial. In several chapters, I expand on applications developed in earlier chapters. Associating new knowledge with something you have mastered already provides positive feedback and a deeper understanding of the language.

This tutorial isn’t about the hottest features of the language; it’s about solid programming techniques and practical examples. After you master the basics of programming Windows applications with Visual Basic 2008 and you feel comfortable with the more advanced examples of this tutorial, you will find it easy to catch up with the topics not discussed in this tutorial. Of course, you will find information about the latest data access techniques, as well as an introduction to LINQ(Language Integrated Query), which is the hottest new component of the Framework.

The Structure of this tutorial

This tutorial isn't meant to be read from cover to cover, and I know that most people don't read computer tutorials or read tutorials this way. Each chapter is independent of the others, although all chapters contain references to other chapters. Each topic is covered in depth; however, I make no assumptions about the reader's knowledge of the topic. As a result, you may find the introductory sections of a chapter too simple. The topics become progressively more advanced, and even experienced programmers will find some new information in most chapters. Even if you are familiar with the topics in a chapter, take a look at the examples. I have tried to simplify many of the advanced topics and demonstrate them with clear, practical examples.

This tutorial tries to teach through examples. Isolated topics are demonstrated with short examples, and at the end of many chapters you'll build a large, practical application (a real-world application) that ''puts together'' the topics and techniques discussed throughout the chapter. You may find some of the more advanced applications a bit more difficult to understand, but you shouldn't give up. Simpler applications would have made my job easier, but the tutorial wouldn't deserve the learning and mastering in your own title, and your knowledge of Visual Basic wouldn't be as complete.

The visual basic tutorial starts with the fundamentals of Visual Basic 2008. You'll learn how to design visual interfaces with point-and-click operations and how to program a few simple events, such as the click of the mouse on a button. After reading the first couple of chapters, you'll understand the structure of a Windows application. Then you'll explore the elements of the visual interface (the basic Windows controls) and how to program them. You'll also learn about the My object and code snippets, two features that make Visual Basic so simple and fun to use. These two objects will also ease the learning process and make it much simpler to learn the features of the language.

Then I discuss in detail the basic components of Windows applications. I explain the most common controls you'll use in building Windows forms in detail, as well as how to work with forms: how to design forms, how to design menus for your forms, how to create applications with multiple forms, and so on. You will find detailed discussions of many Windows controls, as well as how to take advantage of the built-in dialog boxes, such as the Font and Color dialog boxes, in your applications.

Visual Basic 2008 is a truly object-oriented language, and objects are the recurring theme in every chapter. The three following chapters (chapter 10, 11 and 12) contain a formal and more systematic treatment of objects. You will learn how to build custom classes and controls, which will help you understand object-oriented programming a little better. You will also learn about inheritance and will see how easy it is to add custom functionality to existing classes through inheritance.

The following few chapters deal with some of the most common classes of the .NET Framework. The Framework is at the very heart of Windows programming; it's your gateway to the functionality of the operating system itself, and it's going to be incorporated into the next version of Windows. You'll examine several extremely interesting topics such as collections (for example, ArrayLists and HashTables), the classes for manipulating files and folders, the String- Builder class that manipulates text, XML serialization, and a few more, including the Language Integrated Query component (LINQ, which is brand new to the latest version of the Framework). Then you will find a few chapters on graphics. You'll learn how to use the classes of the Framework that generate graphics, and you'll learn how to create vector drawings as well as how to manipulate bitmaps. In Chapter 20, you'll learn everything you need to create printouts with Visual Basic 2008 and see a few practical examples.

The first twenty chapters deal with the fundamentals of the language and Windows applications. Following these chapters, you will find an overview of the data-access tools. The emphasis is on the visual tools, and you will learn how to query databases and present data to the user. You will also find information on programming the basic objects of ADO.NET and write simple data-driven Windows applications. In the last few chapters of this tutorial you will learn about web applications, the basics of ASP.NET 2, how to develop data-bound web applications, and how to write web services.

Following are the list of chapters discussed under the VB.NET 2008 Tutorial

  1. Getting Started with Visual Basic 2008
  2. Using Variables and Data Types
  3. Programming Fundamentals
  4. Windows Controls in VB.NET
  5. Working with Forms
  6. Building Custom Classes
  7. Working with Objects
  8. Custom Windows Controls
  9. Handling Strings, Characters and Dates
  10. Storing Data in Collections
  11. Accessing Folders and Files
  12. Serialization and XML
  13. Querying Collections and XML with LINQ
  14. Drawing and Painting
  15. Manipulating Images and Bitmaps
  16. Printing with Visual Basic 2008





     
 
W3computing.com Copyright 2011 All Rights Reserved
 
  Home | Useful links | Contact us