|
This tour overviews each chapter and outline the many
topics discussed in Visual Basic .NET for Experienced Programmers. Some
of the terms mentioned here might be unfamiliar to you—they will be defined
throughout the book. Every chapter ends with an Internet and Web Resources
section, which lists Web sites that you can visit to learn more about the
topics discussed in that chapter. Please visit
www.deitel.com
and
www.prenhall.com/deitel,
for updated information and additional learning resources.
Chapter 1—Introduction to .NET and Visual Basic .NET
The first chapter presents the history of the Internet,
World Wide Web and various technologies (such as XML and SOAP) that have led
to advances in computing. We introduce the Microsoft .NET initiative and the
Visual Basic .NET programming language, including Web services. We explore the
impact of .NET on software development and software reusability. The chapter
concludes with a tour of the book.
Chapter 2—Introduction to the Visual Studio®
IDE and Visual Basic .NET Programming
Chapter 2 introduces Visual Studio .NET, an integrated
development environment (IDE) that allows programmers to create Visual
Basic .NET programs. Visual Studio .NET enables visual programming, in which
controls (such as buttons and textboxes) are "dragged" and "dropped"
into place, rather than added by typing code. Visual programming increases
software-development productivity by eliminating many tedious programming
tasks. For example, a graphical user interface’s (GUI’s) properties
(information such as size and color) can be modified through the Visual
Studio .NET IDE, allowing changes to be made quickly and causing the results
to appear immediately on the screen. Rather than having to guess how the GUI
will appear while writing a program, programmers view the GUI exactly as it
will appear when the finished program runs. Visual Studio .NET also contains
tools for debugging, documenting and writing code. The chapter presents
features of Visual Studio .NET, including its key windows, and shows how to
compile and run programs. We use the capabilities of Visual Studio .NET to
create a simple Windows application without typing a single line of code. The
chapter also introduces readers to non-visual programming in Visual
Basic .NET. Every concept is presented in the context of a complete working
Visual Basic .NET program and is followed by one or more screen shots showing
actual inputs and outputs as the program executes. This is our Live-Code™
approach. We discuss fundamental tasks, such as how a program inputs data from
its users and how to write arithmetic expressions. This chapter also
demonstrates displaying text in a window called a
MessageBox.
Chapter 3—Control Structures
This chapter introduces the principles of structured
programming, a set of techniques that will help the reader develop clear,
understandable and maintainable programs. The chapter then introduces the use
of control structures that affect the sequence in which statements are
executed. Control structures produce programs that are easily understood,
debugged and maintained. We discuss the three forms of program
control—sequence, selection and repetition— focusing on the
If/
Then/
Else, While, For/
Next, Do While/
Loop, Do Until/
Loop, Do/
Loop While, Do/
Loop Until and Select Case structures.
We explain the Exit
keyword and the logical operators. We build on information presented in the
previous chapter to create programs that are interactive (i.e., they change
their behavior to suit user-supplied inputs). We present an example that
combines visual and non-visual programming techniques. This example builds
upon the first example presented in Chapter 2.
Chapter 4—Procedures and Arrays
A procedure allows the programmer to create a block of code
that can be called upon from various points in a program. Larger programs can
be divided into interacting classes, each consisting of procedures—this is
sometimes called the "divide and conquer" strategy. Programs are divided into
simple components that interact in straightforward ways. We discuss how to
create our own procedures that can take inputs, perform calculations and
return outputs. Recursive procedures (procedures that call themselves)
and procedure overloading, which allows multiple procedures to have the same
name, are introduced. We demonstrate overloading by creating two
Square procedures
that each take an integer (i.e., a whole number) and a floating-point number
(i.e., a number with a decimal point), respectively. This chapter also
introduces arrays, our first data structure. Data structures are crucial to
storing, sorting, searching and manipulating large amounts of information.
Arrays are groups of related data items that allow the programmer to
access any element directly. Rather than creating 100 separate variables that
are all related in some way, the programmer instead can create an array of 100
elements and access these elements by their location in the array. We discuss
how to declare and allocate arrays, and we build on the techniques of the
previous chapter by passing arrays to procedures. Chapter 3 provides essential
background for the discussion of arrays, because repetition structures are
used to iterate through elements in the array. The combination of these
concepts helps programmers create highly structured and well-organized
programs. We discuss multidimensional arrays, which can be used to store
tables of data. We introduce the For
Each/Next
structure, which iterates through arrays.
Chapter 5—Object-Based Programming
Chapter 5 introduces objects and classes. Object technology
has led to considerable improvements in software development, allowing
programmers to create reusable software components. Objects allow programs to
be organized in natural and intuitive ways. This chapter presents the
fundamentals of object-based programming, such as encapsulation, data
abstraction and abstract data types (ADTs). These techniques hide the details
of components so that the programmer can concentrate on the "big picture." We
create a CTime
class, which displays the time in standard and universal formats. We show how
to create reusable software components with assemblies, namespaces and dynamic
link library (DLL) files. We create classes and namespaces, and discuss
properties and the ReadOnly
and Const
keywords. This chapter lays the groundwork for the next two chapters, which
introduce object-oriented programming.
Chapter 6—Object-Oriented Programming: Inheritance
In this chapter, we discuss inheritance—a form of software
reusability in which classes (called derived classes) are created by absorbing
attributes and methods of existing classes (called base classes). The
inheriting class (i.e., the derived class) can contain additional attributes
and methods. We show how finding the commonality between classes of objects
can reduce the amount of work it takes to build large software systems. A
detailed case study demonstrates software reuse and good programming
techniques by finding the commonality among a three-level inheritance
hierarchy: the CPoint,
CCircle and
CCylinder
classes. We discuss the software engineering benefits of object-oriented
programming. Crucial object-oriented programming concepts, such as creating
and extending classes, are presented in this chapter.
Chapter 7—Object-Oriented Programming: Polymorphism
Chapter 7 continues our presentation of object-oriented
programming. We discuss polymorphic programming and its advantages.
Polymorphism permits classes to be treated in a general manner, allowing the
same method call to act differently depending on context (e.g., "move"
messages sent to a bird and a fish result in dramatically different types of
action—a bird flies and a fish swims). In addition to treating existing
classes in a general manner, polymorphism allows new classes to be added to a
system easily. We identify situations in which polymorphism is useful. A
payroll system case study demonstrates polymorphism—the system determines the
wages for each employee differently to suit the type of employee (bosses who
are paid fixed salaries, hourly workers who are paid by the hour, commission
workers who receive a base salary plus commission and piece workers who are
paid per item produced). These programming techniques and those of the
previous chapter allow the programmer to create extensible and reusable
software components.
Chapter 8—Exception Handling
Exception handling is one of the most important topics in
Visual Basic .NET from the standpoint of building mission-critical and
business-critical applications. Users can enter incorrect data, data can be
corrupted and clients can try to access records that do not exist or are
restricted. A simple division-by-zero error may cause a calculator program to
crash, but what if such an error occurs in the navigation system of an
airplane while it is in flight? In some cases, the results of program failure
could be disastrous. Programmers need to know how to recognize the errors
(exceptions) that could occur in software components and handle those
exceptions effectively, allowing programs to deal with problems and continue
executing instead of "crashing." Programmers who construct software systems
from reusable components built by other programmers must deal with the
exceptions that those components may "throw." This chapter covers the details
of Visual Basic .NET exception handling, the termination model of exception
handling, throwing and catching exceptions, and FCL class
Exception.
Chapter 9—Graphical User Interface Concepts: Part 1
Chapter 9 explains how to add sophisticated GUIs to
programs. By using the techniques of rapid application development (RAD),
programmers can create GUIs from reusable components, rather than explicitly
programming every detail. The Visual Studio .NET IDE makes developing GUIs
even easier by allowing the programmer to position components in a window
through so-called visual programming. We discuss how to construct user
interfaces with Windows Forms controls such as labels, buttons,
textboxes and picture boxes. We also introduce events, which are
messages sent by a program to signal to an object or a set of objects that an
action has occurred. Events most commonly signal user interactions with GUI
controls, but also can signal internal actions in a program. We overview event
handling and discuss how to handle events specific to controls, the mouse and
the keyboard.
Chapter 10—Graphical User Interface Concepts: Part 2
Chapter 10 introduces more complex GUI components,
including menus, link labels, panels, list boxes, combo boxes and tab
controls. Multiple Document Interface (MDI) programming is presented,
which allows multiple documents (i.e., forms) to be open simultaneously in a
single GUI. We conclude with an introduction to visual inheritance, which
enables programmers to combine the GUI concepts presented in this chapter with
the object-oriented concepts presented in Chapter 6 to create user interfaces
that can be used and extended by other programmers. Tips are included
throughout the chapter to help the programmer create visually appealing,
well-organized and consistent GUIs.
Chapter 11—Multithreading
Users have come to expect much from applications. Users
want to download files from the Internet, listen to music, print documents and
browse the Web—all at the same time! To do this, programmers need a feature
called multithreading, which allows applications to perform multiple
activities concurrently. The .NET Framework includes built-in capabilities to
enable multithreaded applications, while shielding programmers from complex
details. The .NET languages are better equipped to deal with more
sophisticated multimedia, network-based and multiprocessor-based applications
than those languages that do not have multithreading features. This chapter
introduces the FCL’s threading classes and covers threads, thread life-cycles,
time-slicing, scheduling and priorities. We analyze the producer-consumer
relationship, thread synchronization and circular buffers. This chapter lays
the foundation for creating the multithreaded programs that clients demand.
Chapter 12—Strings, Characters and Regular Expressions
In this chapter, we discuss the processing of words,
sentences, characters and groups of characters. In Visual Basic .NET,
Strings
(groups of characters) are objects. This is yet another benefit of Visual
Basic .NET’s emphasis on object-oriented programming. Objects of type
String contain
methods that can copy, search, extract substrings and concatenate strings with
one another. We introduce class
StringBuilder, which defines string-like objects
that can be modified after initialization. As an interesting example of
strings, we create a card shuffling-and-dealing simulation. We discuss regular
expressions, a powerful tool for searching and manipulating text.
Chapter 13—Graphics and Multimedia
In this chapter, we discuss GDI+ (an extension of the
Graphics Device Interface—GDI), the Windows service that provides the
graphical features used by .NET applications. The extensive graphical
capabilities of GDI+ can make programs more visual and fun to create and use.
We discuss Visual Basic .NET’s treatment of graphics objects and color
control. We also discuss how to draw arcs, polygons and other shapes. This
chapter also demonstrates how to use various pens and brushes to create color
effects and includes an example that demonstrates gradient fills and textures.
We also introduce techniques for turning text-only applications into exciting,
aesthetically pleasing programs that even novice programmers can write with
ease. The second half of the chapter focuses on audio, video and speech
technology. We discuss adding sound, video and animated characters to programs
(primarily using existing audio and video clips). You will see how easy it is
to incorporate multimedia into Visual Basic .NET applications. This chapter
introduces an exciting technology called Microsoft Agent for adding
interactive animated characters to a program. Each character allows users
to interact with the application, using more natural human communication
techniques, such as speech. The agent characters respond to mouse and keyboard
events, speak and hear (i.e., they support speech synthesis and speech
recognition). With these capabilities, your applications can speak to users
and actually respond to their voice commands!
Chapter 14—Files and Streams
Imagine a program that could not save data to a file. Once
the program is closed, all the work performed by the program is lost forever.
For this reason, this chapter is one of the most important for programmers who
will be developing commercial applications. We introduce FCL classes for
inputting and outputting data. A detailed example demonstrates these concepts
by allowing users to read and write bank account information to and from
files. We introduce the FCL classes and methods that help perform input and
output conveniently—they demonstrate the power of object-oriented programming
and reusable classes. We discuss benefits of sequential files, random-access
files and buffering. This chapter lays the groundwork for the material
presented in Chapter 19, Networking: Streams-Based Sockets and Datagrams.
Chapter 15—Extensible Markup Language (XML)
The Extensible Markup Language (XML) derives from SGML
(Standard Generalized Markup Language), which became an industry standard in
1986. Although SGML is employed in publishing applications worldwide, it has
not been incorporated into the mainstream programming community because of its
sheer size and complexity. XML is an effort to make SGML-like technology
available to a much broader community. XML, created by the World Wide Web
Consortium (W3C), describes data in a portable format. XML differs in concept
from markup languages such as HTML, which only describes how information is
rendered in a browser. XML is a technology for creating markup languages for
virtually any type of information. Document authors use XML to create entirely
new markup languages to describe specific types of data, including
mathematical formulas, chemical molecular structures, music, recipes and much
more. Markup languages created with XML include XHTML (Extensible HyperText
Markup Language, for Web content), MathML (for mathematics), VoiceXML™ (for
speech), SMIL™ (Synchronized Multimedia Integration Language, for multimedia
presentations), CML (Chemical Markup Language, for chemistry) and XBRL
(Extensible Business Reporting Language, for financial data exchange). The
extensibility of XML has made it one of the most important technologies in
industry today and it is being integrated into almost every field. Companies
and individuals constantly are finding new and innovative uses for XML. In
this chapter, we present examples that illustrate the basics of marking up
data as XML. We demonstrate XML-derived markup languages, such as XML
Schema (for checking an XML document’s grammar), XSLT (Extensible
Stylesheet Language Transformations, for transforming an XML document’s
data into another text-based format such as XHTML) and Microsoft’s BizTalk™
(for marking up business transactions).
Chapter 16—Database, SQL and ADO .NET
Data storage and access are integral to creating powerful
software applications. This chapter discusses .NET support for database
manipulation. Today's most popular database systems are relational databases.
In this chapter, we introduce the Structured Query Language (SQL) for
performing queries on relational databases. We introduce ActiveX Data Objects
ADO .NET—an extension of ADO that enables .NET applications to access and
manipulate databases. ADO .NET allows data to be exported as XML, which
enables applications that use ADO .NET to communicate with a variety of
programs that understand XML. We show the reader how to create database
connections, using tools provided in Visual Studio .NET and how to use
ADO .NET classes to query a database.
Chapter 17—ASP .NET, Web Forms and Web Controls
Previous chapters demonstrated how to create applications
that execute locally on the user’s computer. In this chapter and Chapters 18
and 21, we discuss how to create Web-based applications using Active Server
Pages (ASP) .NET. This is a crucial aspect of .NET and of Microsoft’s vision
of how software should be developed and deployed on the Internet. ASP .NET is
an integral technology for creating dynamic Web content marked up as HTML.
Web Forms provide GUIs for ASP .NET pages and can contain Web controls,
such as labels, buttons and textboxes with which users interact. Like Windows
Forms, Web Forms are designed using visual programming. This chapter presents
many interesting examples, which include an online guest book application and
a multi-tier, database-intensive application that allows users to query a
database for a list of publications by a specific author. Debugging Web Forms
using the Trace
property also is discussed.
Chapter 18—ASP .NET and Web Services
Chapter 18 continues our discussion of ASP .NET. In this
chapter, we introduce Web services, which are programs that "expose" services
(i.e., methods) to clients over the Internet, intranets and extranets. Web
services offer increased software reusability by allowing services on
disparate platforms to interact with each other seamlessly. This chapter
presents several interesting examples that include Web services for
manipulating huge numbers (up to 100 digits), simulating the card game of
blackjack and implementing an airline reservation system. One particularly
interesting example is our temperature server, a Web service that gathers
weather information for dozens of cities in the United States.
Chapter 19—Networking: Streams-Based Sockets and Datagrams
Chapter 19 introduces the fundamental techniques of
streams-based networking. We demonstrate how streams-based sockets allow
programmers to hide many networking details. With sockets, networking is as
simple as if the programmer were reading from and writing to a file. We also
introduce datagrams in which packets of information are sent between
programs. Each packet is addressed to its recipient and sent out to the
network, which routes the packet to its destination. The examples in this
chapter focus on communication between applications. One example demonstrates
using streams-based sockets to communicate between two Visual Basic .NET
programs. Another similar example sends datagrams between applications. We
also show how to create a multithreaded-server application that can
communicate with multiple clients in parallel. In this client/server
tic-tac-toe game, the server maintains the status of the game and two clients
communicate with the server to play the game.
Chapter 20—Data Structures and Collections
This chapter discusses arranging data into aggregations
such as linked lists, stacks, queues and trees. Each data structure has
properties that are useful in a wide variety of applications, from sorting
elements to keeping track of procedure calls. We discuss how to build each of
these data structures. This is also a valuable experience in crafting useful
classes. In addition, we cover pre-built collection classes in the FCL. These
collections classes store sets, or collections, of data and provide
functionality that allows the developer to sort, insert, delete and retrieve
data items. Different collection classes store data in different ways. This
chapter focuses on classes Array,
ArrayList,
Stack and
Hashtable,
discussing the details of each. When possible, Visual Basic .NET programmers
should use the FCL to find appropriate data structures, rather than
implementing these data structures themselves. This chapter reinforces much of
the object technology discussed in Chapters 5–7, including classes,
inheritance and composition.
Chapter 21—Mobile Internet Toolkit
The demand for wireless applications is growing rapidly.
Within the next two years, the number of people browsing the Web from wireless
devices will exceed the number browsing from desktop computers. The Mobile
Internet Toolkit (MIT) extends Visual Studio .NET by providing a set of
FCL classes for creating Web applications for mobile devices. We introduce
mobile Web controls and mobile Web Forms that can be used to create ASP .NET
applications that target a wide range of mobile devices. Furthermore, mobile
Web applications created using the MIT can be designed to determine the type
of device making the request and generate markup appropriate for that specific
device. For example, a personal digital assistant and mobile phone can both
request the same page, but receive different markup. This is known as
device-specific rendering, a process demonstrated in this chapter. Finally, we
demonstrate how to consume a Web service from a mobile Web application. In
this example, we show how similar it is to access a Web service from a mobile
application, as it is to access a Web service from a Windows application.
Appendix A—Operator Precedence Chart
This appendix lists Visual Basic .NET operators and their
precedence.
Appendix B—Visual Studio .NET Debugger
This appendix introduces the Visual Studio .NET debugger
for locating logic errors in programs. Key features include setting
"breakpoints," stepping through programs line-by-line and "watching"
variables.
Appendix C—ASCII Character Set
This appendix contains a table of the 128 ASCII (American
Standard Code for Information Interchange) alphanumeric symbols and their
corresponding integer values.
Appendix D—Unicode®
This appendix introduces the Unicode Standard, an encoding
scheme that assigns unique numeric values to the characters of most of the
world’s languages. We include a Windows application that uses Unicode encoding
to print welcome messages in several languages.
[ top ]
© 1992-2005. Deitel & Associates, Inc. All Rights Reserved.
|