O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How This Book Is Structured

VB.NET Language in a Nutshell is divided into three parts. The first part of the book, The Basics, is an introduction to the main features and concepts of Visual Basic programming. Given the newness of VB.NET, even seasoned VB professionals should find items of interest here. If you’re new to VB, this part of the book is essential reading. It’s divided into the following chapters:

Chapter 1

In this chapter, you’ll see how Visual Basic has evolved into the VB.NET language of today and get some sense of how and why VB.NET is different from previous versions of Visual Basic.

Chapter 2

This chapters discusses the entry points that allows the .NET runtime to execute your code and shows how to structure the code in a Visual Basic program.

Chapter 3

This chapter looks at the standard Visual Basic data types and how you use them. Behind the scenes, Visual Basic takes advantage of the .NET Framework’s common type system, so the chapter also examines the .NET data types and the way in which VB wraps these data types.

Chapter 4

With the release of its .NET version, Visual Basic finally becomes a fully object-oriented programming language. This chapter discusses the basic concepts of object-orientated programming and shows how you implement VB’s object-oriented features in your programming.

Chapter 5

This chapter surveys some of the new features of the .NET Framework that most impact the VB developer. These include namespaces, the Common Language Runtime (CLR), and assemblies.

Chapter 6

The .NET Framework Class Library replaces portions of the Win32 API, as well as many of the individual object models that VB programmers have worked with over the past five years, with a single class library. This chapter offers a very fast-paced overview of the Framework Class Library and some of its features.

Chapter 7

While handling events was more or less automatic in previous versions of VB and even in VBScript, you typically have to “wire” events to your code in VB.NET. This chapter shows how to do that.

Chapter 8

The .NET Framework supports attributes, an extensible mechanism that allows you to store customized items of information about a particular program element in an assembly’s metadata. This makes it possible to modify the behavior of the compiler, of a design time environment, or of the runtime environment if a particular attribute is present. This chapter explains what attributes are in greater detail, introduces the syntax of attribute-based programming, and shows you how to define and consume custom attributes.

Chapter 9

Visual Basic now offers two techniques for error handling. The first, which uses the On Error statement, is termed unstructured error handling and is a traditional part of VB. The second, which uses the Try...Catch... Finally construct, is termed structured exception handling and is new to VB.NET. In this chapter, we’ll show you how to use both.

The second part of this book, Part II, consists of one large chapter, Chapter 10, which thoroughly details all the functions, statements, directives, objects, and object members that make up the VB.NET language.

The third and final section consists of the following appendixes:

Appendix A

A discussion of language changes from VB 6 to VB.NET.

Appendix B

A listing of all VB.NET functions, statements, and major keywords by category.

Appendix C

A list of the operators supported by VB.NET, along with a slightly more detailed treatment of the Boolean and bitwise operators.

Appendix D

A list of VB.NET intrinsic constants, as well as VB.NET enumerations and their members.

Appendix E

For the first time, Visual Basic includes a command-line compiler — you can actually use NotePad as your primary “development environment” for Visual Basic (although we are not necessarily recommending this approach) and use the compiler to compile your code. This appendix documents the operation of the Visual Basic command-line compiler.

Appendix F

A list of the language elements that have dropped out of the Visual Basic language as a result of its transition to the .NET Framework.

The Format of the Language Reference

The following template has been used in preparing the entries for functions, procedures, statements, properties, and methods that appear in Chapter 10:


For functions, procedures, classes, or class members, the class to which the item belongs.

Named Arguments

Typically, we indicate if a function, procedure, or method does not accept named arguments. Otherwise, you can assume that the language element supports both named and positional arguments.


This section uses standard conventions to give a synopsis of the syntax used for the language item. It also lists parameters and replaceable items (and indicates whether they’re optional or not), lists their data types, and provides a brief description.

Return Value

For functions, this section provides a brief description of the value or data type returned by the function. For properties, it describes the data type of the property.


A short description of what the language element does, and when and why it should be used.

Rules at a Glance

This section describes the main points of how to use the function. The dos and don’ts are presented in the form of a bulleted list to let you quickly scan through the list of rules. In the vast majority of cases, this section goes well beyond the basic details found in the VB documentation.


We’ve tried to avoid the kind of gratuitous examples commonly found in documentation that only manage to illustrate the obvious. Instead, we’ve used short code fragments that help to enhance your understanding of how the language element is used.

Programming Tips and Gotchas

This is the most valuable section of Chapter 10, in our opinion, and it is gained from years of experience using the VB language in a variety of projects and applications. The information included here will save you countless hours of head scratching and experimentation. Often, this is the stuff Microsoft doesn’t tell you!

See Also

A simple cross-reference list of related or complimentary language elements.

A modified version of the template has been used for statements and attributes.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required