Thông tin tài liệu
www.it-ebooks.info
www.it-ebooks.info
Programming Visual Basic 2008
www.it-ebooks.info
Other Microsoft .NET resources from O’Reilly
Related titles
ADO.NET 3.5 Cookbook
™
Building a Web 2.0 Portal
with ASP.NET 3.5
C# Cookbook
™
C# 3.0 in a Nutshell
C# 3.0 Pocket Reference
Learning ASP.NET 3.5
Programming ASP.NET 3.5
Programming ASP.NET AJAX
Visual Basic 2005 Cookbook
™
.NET Books
Resource Center
dotnet.oreilly.com is a complete catalog of O’Reilly’s books on
.NET and related technologies, including sample chapters and
code examples.
ONDotnet.com provides independent coverage of fundamental,
interoperable, and emerging Microsoft .NET programming and
web services technologies.
Conferences
O’Reilly brings diverse innovators together to nurture the ideas
that spark revolutionary industries. We specialize in document-
ing the latest tools and systems, translating the innovator’s
knowledge into useful skills for those in the trenches. Visit
conferences.oreilly.com for our upcoming events.
Safari Bookshelf (safari.oreilly.com) is the premier online refer-
ence library for programmers and IT professionals. Conduct
searches across more than 1,000 books. Subscribers can zero in
on answers to time-critical questions in a matter of seconds.
Read the books on your Bookshelf from cover to cover or sim-
ply flip to the page you need. Try it today for free.
www.it-ebooks.info
Programming
Visual Basic 2008
Tim Patrick
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Taipei
•
Tokyo
www.it-ebooks.info
Programming Visual Basic 2008
by Tim Patrick
Copyright © 2008 Tim Patrick. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor:
John Osborn
Production Editor:
Rachel Monaghan
Copyeditor:
Audrey Doyle
Proofreader:
Rachel Monaghan
Indexer:
Ellen Troutman Zaig
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Robert Romano
Printing History:
May 2008: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Programming Visual Basic 2008, the image of a bufflehead duck, and related trade
dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book uses RepKover
™
, a durable and flexible lay-flat binding.
ISBN: 978-0-596-51843-1
[M]
www.it-ebooks.info
To Maki, my lovely wife
www.it-ebooks.info
www.it-ebooks.info
vii
Table of Contents
Preface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
xv
1. Introducing .NET
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
Before .NET 1
Back to Introducing .NET 2
The .NET Object 3
The Parts of the .NET Framework 7
From Source Code to EXE 16
What About Visual Studio and Visual Basic? 17
Visual Studio 2008 18
Summary 22
Project 23
2. Introducing Visual Basic
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
30
The History of the Visual Basic Revolution 30
Visual Basic from the Inside Out 32
The Basics of Logic and Data 32
Data Types and Variables 35
Intermission 44
Comments 44
Option Statements 45
Basic Operators 47
Using Functions and Subroutines 49
Conditions 50
Loops 54
Creating Your Own Procedures 57
Other Flow Control Features 61
www.it-ebooks.info
viii | Table of Contents
Events and Event Handlers 64
Namespaces 66
The My Namespace 69
Summary 70
Project 70
3. Introducing the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
75
The Library Project 76
The Needs of the Users 79
The Life of a Project 83
Summary 90
Project 90
4. Designing the Database
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
95
Relational Databases 95
SQL Server 2005 98
SQL 100
Using Databases in Visual Basic 107
Documenting the Database 108
Summary 109
Project 109
5. .NET Assemblies
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
126
What Is an Assembly? 126
What’s Inside an Assembly? 128
Assemblies and Applications 131
The My Namespace and Assemblies 132
Directives and Assemblies 134
Summary 136
Project 137
6. Data and Data Types
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
151
The Nature of Computer Data 151
Data in .NET 153
Visual Basic Data Types 158
Literals 159
Constants 160
www.it-ebooks.info
[...]... basic step-by-step instructions can successfully program in Visual Basic If you are unsure about your ability to quantify tasks in this way, you might want to start out with a book on basic programming concepts xv www.it-ebooks.info You might know how to program in Visual Basic or NET, but maybe not And that’s OK, because this book will teach you Most of the chapters introduce important topics in Visual. .. part of Visual Studio Once they are installed, you can create a new chapter-specific project right from the File ➝ New Project menu in Visual Studio Appendix A has all of the download and installation details I wrote the project code using Visual Basic 2008 Professional Edition Some portions may not be compatible with earlier NET versions of the language None of it is compatible with Visual Basic 6.0... comments When it came time to focus on Visual Basic s 2008 release, I also received fantastic input from Chris Williams, Daniel Seara, Ron Petrusha, and Sander Gerz Many thanks to Joe Binder, Jay Roxe, Prasadi de Silva, and Eric Knox, all members of the Visual Basic team at Microsoft Each of them fielded a relentless onslaught of questions about esoteric Visual Basic and NET features, and provided answers... amount of example code from this book into your product’s documentation requires that you abide by the terms of the software license agreement found in Appendix B We appreciate, but do not require, attribution An attribution usually includes the title, author, publisher, and ISBN For example: Programming Visual Basic 2008, by Tim Patrick Copyright 2008 Tim Patrick, 978-0-596-51843-1.” If you feel your... Table of Contents www.it-ebooks.info Preface 1 Welcome to Programming Visual Basic 2008! I know you’re going to enjoy it; I’ve read it five times already You’re probably anxious to get to Chapter 1, but I recommend you read this preface to make sure you paid for the right book Who Is Reading This Book? Writing a book is a lot like writing a Visual Basic application Well, except for the part about finding... only does it refer to these core elements of the CTS, but it is also used when talking about just the Visual Basic- specific value types (more often called the Visual Basic “data types”) The nickname for structures is “user-defined types,” yet another confusing use of “type.” Programmers who used Visual Basic before its NET incarnation also remember “Type” as the language statement used to create user-defined... exist somewhere in the hierarchy, although not every class descends from System Many of the supporting features specific to Visual Basic appear in the Microsoft.VisualBasic namespace, which has “Microsoft” as its root node instead of “System.” When you create new projects in Visual Basic, the name of the project is, by default, a new top-level node in the hierarchy If you create a new Windows application... www.it-ebooks.info 14 Application Settings 392 A Short History of Settings Settings in Visual Basic 2008 Summary Project 392 394 400 401 15 Files and Directories 416 Traditional Visual Basic File Management Manipulating Files Through Streams File Management with the My Namespace Summary Project 417 418 424 427 428... Types Common Visual Basic Functions Summary Project 161 162 165 166 167 172 172 175 176 181 182 7 Windows Forms 187 Inside a Windows Application Windows in NET Making Forms Useful Summary Project 187 191 210 212 212 8 Classes and Inheritance 219 Object-Oriented Programming Concepts OOP in Visual Basic and NET... Object-Oriented Programming Concepts OOP in Visual Basic and NET Related Issues Summary Project 219 224 241 244 244 9 Functional Programming 253 Lambda Expressions Object Initializers Error Handling in Visual Basic The Nature of Errors in Visual Basic Unstructured Error Handling Structured Error Handling Unhandled Errors Managing Errors Summary Project 253 259 260 . free. www.it-ebooks.info Programming Visual Basic 2008 Tim Patrick Beijing • Cambridge • Farnham • Köln • Sebastopol • Taipei • Tokyo www.it-ebooks.info Programming Visual Basic 2008 by Tim Patrick Copyright © 2008. Framework 7 From Source Code to EXE 16 What About Visual Studio and Visual Basic? 17 Visual Studio 2008 18 Summary 22 Project 23 2. Introducing Visual Basic . . . . . . . . . . . . . . . . . . History of the Visual Basic Revolution 30 Visual Basic from the Inside Out 32 The Basics of Logic and Data 32 Data Types and Variables 35 Intermission 44 Comments 44 Option Statements 45 Basic Operators
Ngày đăng: 29/03/2014, 07:20
Xem thêm: Programming Visual Basic 2008 doc, Programming Visual Basic 2008 doc