VB.NET Language in a Nutshell: A Desktop Quick Reference

VB.NET Language in a Nutshell: A Desktop Quick Reference

by Steven Roman PhD, Ron Petrusha, Paul Lomax
     
 

The extensive changes to Visual Basic and the newness of the .NET platform call for a VB .NET reference guide oriented toward professional developers—those deeply experienced in Visual Basic and those adding VB .NET to their list of mastered languages. VB .NET Language in a Nutshell answers the call. As a reference book, it doesn't waste space on simple

…  See more details below

Overview

The extensive changes to Visual Basic and the newness of the .NET platform call for a VB .NET reference guide oriented toward professional developers—those deeply experienced in Visual Basic and those adding VB .NET to their list of mastered languages. VB .NET Language in a Nutshell answers the call. As a reference book, it doesn't waste space on simple concepts, but documents, using practical examples, how language elements work, alternative approaches, optimal usage, and potential pitfalls.As a quick introduction, the first section of VB .NET Language in a Nutshell leads you through the important areas of programming VB .NET, including:

  • Variables and Data Types
  • Introduction to Object Oriented Programming
  • The .NET Framework: General Concepts
  • The .NET Framework Class Library
  • Delegates and Events
  • Error Handling
The meat of the book is the alphabetical reference to the functions, statements, directives, objects, and object members that make up the VB .NET language. As an experienced developer, you can quickly get the whole story on a language element that interests you or seems to be behaving unexpectedly in your code. To ease your transition to .NET, there's a "VB .NET/VB 6 Differences" section for each language element.A hefty appendix section includes:
  • What's New and Different in VB .NET
  • Language Elements by category
  • Operators
  • Constants and Enumerations
  • The VB .NET Command Line Compiler
  • VB 6 Language Elements Not Supported by VB .NET
No matter how much experience you have programming with VB, this is the kind of book you'll want to have close by, both as your standard reference guide and as a tool for troubleshooting and identifying programming problems.

Read More

Editorial Reviews

bn.com
The Barnes & Noble Review
Can it be a whole decade since Microsoft revolutionized programming by introducing Visual Basic? Ten years later, there are somewhere between five and eight million VB programmers worldwide -- and we'll bet the majority of them are greeting Microsoft's new VB.NET with trepidation.

In many respects, this is the VB of our dreams: streamlined, modernized, object-oriented through-and-through, and an "equal player" in the new .NET universe, no longer playing second fiddle to C++ (or even C#). On the other hand, the language has changed extensively: slavish upward compatibility was not a VB.NET design goal. Elements that were once statements are now functions or procedures. Worse, after all these years, we'd finally started to get comfortable with the Component Object Model -- and now it's gone.

To program with VB.NET, you're going to have to "think differently," to swipe a cliché. And it's going to take awhile to get comfortable with the new paradigm -- not to mention the new statements, functions, procedures, directives, and objects. That's where VB.NET Language in a Nutshell comes in. It'll be your rock-solid professional reference as you start working with VB.NET -- and for years thereafter.

The authors assume that you've either been programming for some time (quite possibly with Visual Basic 6) or you're looking for a primary reference to accompany whatever VB.NET tutorials you're already using. Having said that, the first hundred pages of VB.NET Language in a Nutshell deliver concise, insightful discussions of several of the most important issues you face in developing with VB.NET, whatever your background.

For example, you'll find a chapter on VB.NET's standard data types and how VB.NET wraps the data types built into the .NET Framework; and another on VB.NET's approach to object-oriented programming. There's coverage of how the .NET Framework Class Library replaces portions of the Win32 API, and what that means to you as a developer. You have to pay more attention to event handling in VB.NET than you did with VB6 or VBScript, and there's a chapter that shows you how. VB.NET adds a new "structured" option for error handling to accompany the hoary old On Error statement; the authors show you how (and when) to use each.

As you might expect, the authors intend VB.NET Language in a Nutshell to be especially valuable for those upgrading from VB6. To that end, they've provided extensive coverage of the differences between the two languages, both in two detailed appendices and throughout its language reference. (In VB6, if you declare a variable using Dim without specifying a specific data type, it'll be a Variant -- in VB.NET, it'll be an Object. In VB6's Lock statement, you can separate fromrecord and torecord arguments with the "To" keyword; but not in VB.NET. On and on the differences go, large and small.)

The heart of this book is its 500+ page language reference section. Unlike other .NET books, this one focuses specifically on VB.NET's core language elements: its statements, functions, procedures, directives, and objects -- especially the Err and Collection objects. (You'll find some information on the .NET Base Class Library -- the services provided by the .NET Framework. But the authors have restricted that to .NET elements which replace commonly used VB6 features, or significantly expand the functionality of existing VB.NET features.)

To give you fast access to what you're looking for (even if you're not sure what it's called), Appendix B lists every VB.NET function, statement, and major keyword, organized by category. When you do jump to the reference entry, you'll find all the information you need -- presented with maximum clarity and brevity. Syntax. Descriptions. Rules at a glance. Programming tips. And, in many cases, example code.

Best of all, the authors have done a yeoman job cataloguing "gotchas" that are waiting to bite you. (Here's just one: if you need to convert a string representation of a number to a numeric, don't use Val: unlike VB.NET's datatype conversion features, Val doesn't take into account the regional settings of the system it's running on, and can inadvertently return the wrong data.)

Put simply, if you're going to depend on VB.NET, you'll really depend on VB.NET Language in a Nutshell. Every day. (Bill Camarda)

Bill Camarda is a consultant, writer, and web/multimedia content developer with nearly 20 years' experience in helping technology companies deploy and market advanced software, computing, and networking products and services. He served for nearly ten years as vice president of a New Jersey–based marketing company, where he supervised a wide range of graphics and web design projects. His 15 books include Special Edition Using Word 2000 and Upgrading & Fixing Networks For Dummies®, Second Edition.

Read More

Product Details

ISBN-13:
9780596000929
Publisher:
O'Reilly Media, Incorporated
Publication date:
08/08/2001
Series:
In a Nutshell (O'Reilly) Series
Edition description:
First Edition
Pages:
656
Product dimensions:
6.36(w) x 9.00(h) x 1.25(d)

Related Subjects

Read an Excerpt

Chapter 1: Introduction

Since its introduction in 1991, Microsoft Visual Basic has enjoyed unprecedented success. In fact, in slightly more than a decade, it has become the world's most widely used programming language, with an installed base of somewhere between three and five million developers (depending on the particular source you use and whether the estimate includes only the retail versions of the Visual Basic product or the hosted version of Visual Basic for Applications (VBA) as well).

The reason for this success is twofold. First, Visual Basic has excelled as a rapid application development (RAD) environment for corporate and commercial applications. Second, Visual Basic offers a programming language and development environment noted for its simplicity and ease of use, making it an extremely attractive choice for those new to programming.

With the release of its new .NET platform, Microsoft also released a new version of the Visual Basic language, Visual Basic .NET. VB .NET is a from-the-ground-up rewrite of Visual Basic that not only adds a number of new features, but also differs significantly from previous versions of Visual Basic. From a high-level view, two of these differences are especially noteworthy:

  • Until the release of VB .NET, Microsoft focused on creating a unified version of VBA, the language engine used in Visual Basic, which could serve as a "universal batch language" for Windows and Windows applications. With Version 6 of Visual Basic, this goal was largely successful: VB 6.0 featured VBA 6.0, the same language engine that drives the individual applications in the Microsoft Office 2000 suite, Microsoft Project, Microsoft FrontPage, Microsoft Visio, and a host of popular third-party applications such as AutoDesk's AutoCAD and Corel's WordPerfect Office 2000. With the release of VB .NET, this emphasis on a unified programming language has, for the moment at least, faded into the background, as the hosted version of Visual Basic continues to be VBA rather than VB .NET.

  • Since Version 4, Visual Basic had increasingly been used as a kind of "glue language" to access COM components and their object models, such as ActiveX Data Objects (ADO), Collaborative Data Objects (CDO), or the Outlook object model. Although VB .NET supports COM for reasons of "backward compatibility," VB .NET is designed primarily to work with the .NET Framework rather than with COM.
You may be wondering why Microsoft would totally redesign a programming language and development environment that is so wildly successful. As we shall see, there is some method to this madness.

Why VB .NET

When Visual Basic was introduced in 1991, Windows 3.0 was a fairly new operating system in need of application and utility software. Although Windows 3.0 itself had proven successful, the graphical applications that offered native support for Windows-and upon whose release the ultimate success or failure of Windows would depend-were slow in coming. The major problem was that C and C++ programmers, who had produced the majority of applications for the MS-DOS operating system, were faced with a substantial learning curve in writing Windows applications and adapting to Windows' event-driven programming model.

The introduction of Visual Basic immediately addressed this problem by offering a programming model that was thoroughly consistent with Windows' graphical nature. Although Windows marked a radical change in the way programs were written, C and C++ programmers continued to produce code as they always had: a text editor was used to write source code, the source code was compiled into an executable, and the executable was finally run under Windows. Visual Basic programmers, on the other hand, worked in a programming environment that its critics derisively labeled a "drawing program." Visual Basic automatically created a form (or window) whenever the developer began a new project. The developer would then "draw" the user interface by dragging and dropping controls from a toolbox onto the form. Finally, the developer would write code snippets that responded to particular events (such as the window loading or the window being resized). In other words, Visual Basic's initial success was due to its ease of use, which in turn reflected that Visual Basic offered a graphical programming environment that was entirely consistent with the graphical character of Windows itself.

To get some sense of the revolutionary character of Visual Basic, it is instructive to compare a simple "Hello World" program for Windows 3.0 written in C (see Example 1-1) with one written in Visual Basic (see Example 1-2). While the former program is over two pages long, its Visual Basic counterpart takes only three lines of code-and two of them are provided automatically by the Visual Basic environment itself.

While Version 1.0 of Visual Basic was relatively underpowered, Microsoft displayed a firm commitment to Visual Basic and worked very hard to increase its power and flexibility with each new release. By the time Version 3.0 was released, Visual Basic offered a programming paradigm that was completely intuitive, making it easy for novice programmers to get started and produce simple applications very quickly. At the same time, particularly through its ability to access the Windows Application Programming Interface (API) and through its support for add-on controls, Visual Basic had become a programming tool capable of creating applications of considerable sophistication and complexity.

Like VB .NET, Visual Basic Version 4.0, which was released in 1995 to support Microsoft's 32bit family of operating systems, was a complete rewrite of Visual Basic. It featured limited support for object-oriented programming in the form of class modules (CLS files) and the ability to generate not only Windows executables, but ActiveX DLLs (also known as COM components) as well. In the periods shortly before and after the release of VB 4, the character of programming changed dramatically. The rise of the Internet as an application platform meant that standalone Windows applications were becoming less and less necessary. The increased prominence of distributed applications that assumed the presence of the Internet marked another change in programming paradigms. Yet, Visual Basic's real strength remained as it always had been: a great platform for developing standalone Windows applications.

This disparity between Visual Basic's strengths and the prevailing programming paradigm, which emphasized distributed applications and the Internet, created something of a contradiction. On the one hand, Visual Basic excelled at graphically depicting the Windows interface. On the other hand, developers were creating fewer and fewer Windows interfaces. Instead, they were now using Visual Basic primarily to write source code that would eventually be compiled into middle-tier components. Ironically, a programming environment whose real strength and point of departure was its graphical character was now being used as a text editor, in very much the same way the first generation of Windows programmers used text editors to create C source code for Windows applications.

Moreover, as the popularity of the Internet grew, it became clearer that Visual Basic was not a particularly good platform for developing Internet applications. With VB 6, Microsoft introduced Web Classes as the preferred technology for Internet application development. Yet, the metaphor presented by Web Classes (which focused on separating a web application's presentation from its programmatic functionality) was confusing to developers, and as a result, Web Classes never became popular. While VB remained critically important for developing middle-tier components for distributed applications, both it and the Visual Basic community that grew up around it remained strangely isolated from the Internet as an application platform.

Numerous detractors have labeled VB .NET as an entirely new language with little relationship to previous versions of Visual Basic-a dubious innovation foisted on the Visual Basic community by Microsoft in an attempt to sell a new version of its development products. However, we don't agree. Instead, we view the introduction of VB .NET as a logical and even necessary step forward in the development of Visual Basic as a premier programming language. The goal of VB .NET is to address the limitations of Visual Basic as a development environment and bring it into the Internet age so that it can remain the major platform for developing applications of all kinds. Very much like Visual Basic 1.0 offered a graphical interface that was suitable for Windows applications, VB .NET and Visual Studio .NET aim at providing a graphical interface that is suitable for developing web applications and for taking full advantage of the Internet as an application-development platform, as well as for developing Windows applications and components....

Read More

Meet the Author

Ron Petrusha is an editor for O'Reilly and is the author/coauthor of many books, including VBScript in a Nutshell. Ron has a background in quantitative labor history, specializing in Russian labor history, and holds degrees from the University of Michigan and Columbia University. He began working with computers in the mid 1970s, programming in SPSS (a programmable statistical package) and FORTRAN on the IBM 370 family. Since then, he has been a computer book buyer, an editor of a number of books on Windows and Unix, and a consultant on projects written in dBASE, Clipper, and Visual Basic.

Paul Lomax, author of O'Reilly's VB & VBA in a Nutshell and a coauthor of VBScript in a Nutshell, is an experienced VB programmer with a passion for sharing his knowledge—and his collection of programming tips and techniques gathered from real-world experience.

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >