1. Trang chủ
  2. » Công Nghệ Thông Tin

visual basic net how to program 2e

1,6K 395 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.565
Dung lượng 16,11 MB

Nội dung

Contents Contents vii Illustrations xxviii Preface xxxvii 1 Introduction to Computers, Internet and Visual Basic .NET 1 1.1 Introduction 2 1.2 What Is a Computer? 3 1.3 Computer Organization 4 1.4 Evolution of Operating Systems 5 1.5 Personal Computing, Distributed Computing and Client/Server Computing 5 1.6 Machine Languages, Assembly Languages and High-Level Languages 6 1.7 Visual Basic .NET 7 1.8 C, C++, Java™ and C# 9 1.9 Other High-Level Languages 10 1.10 Structured Programming 10 1.11 Key Software Trend: Object Technology 11 1.12 Hardware Trends 13 1.13 History of the Internet and World Wide Web 14 1.14 World Wide Web Consortium (W3C) 15 1.15 Extensible Markup Language (XML) 16 1.16 Introduction to Microsoft .NET 17 1.17 .NET Framework and the Common Language Runtime 18 1.18 Tour of the Book 20 1.19 Internet and World Wide Web Resources 29 VIII 2 Introduction to the Visual Studio .NET IDE 33 2.1 Introduction 34 2.2 Overview of the Visual Studio .NET IDE 34 2.3 Menu Bar and Toolbar 37 2.4 Visual Studio .NET IDE Windows 39 2.4.1 Solution Explorer 40 2.4.2 Toolbox 41 2.4.3 Properties Window 41 2.5 Using Help 44 2.6 Simple Program: Displaying Text and an Image 45 2.7 Internet and World Wide Web Resources 55 3 Introduction to Visual Basic Programming 61 3.1 Introduction 62 3.2 Simple Program: Printing a Line of Text 62 3.3 Another Simple Program: Adding Integers 70 3.4 Memory Concepts 73 3.5 Arithmetic 74 3.6 Decision Making: Equality and Relational Operators 78 3.7 Using a Dialog to Display a Message 82 3.8 Internet and World Wide Web Resources 88 4 Control Structures: Part 1 96 4.1 Introduction 97 4.2 Algorithms 97 4.3 Pseudocode 98 4.4 Control Structures 98 4.5 If/Then Selection Structure 102 4.6 If/Then/Else Selection Structure 104 4.7 While Repetition Structure 106 4.8 Do While/Loop Repetition Structure 108 4.9 Do Until/Loop Repetition Structure 109 4.10 Assignment Operators 110 4.11 Formulating Algorithms: Case Study 1 (Counter-Controlled Repetition) 112 4.12 Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 2 (Sentinel-Controlled Repetition) 114 4.13 Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 3 (Nested Control Structures) 119 4.14 Formulating Algorithms with Top-Down, Stepwise Refinement: Case Study 4 (Nested Repetition Structures) 123 4.15 Introduction to Windows Application Programming 127 5 Control Structures: Part 2 144 5.1 Introduction 145 5.2 Essentials of Counter-Controlled Repetition 145 5.3 For/Next Repetition Structure 146 5.4 Examples Using the For/Next Structure 149 IX 5.5 Select Case Multiple-Selection Structure 155 5.6 Do/Loop While Repetition Structure 159 5.7 Do/Loop Until Repetition Structure 160 5.8 Using the Exit Keyword in a Repetition Structure 162 5.9 Logical Operators 164 5.10 Structured Programming Summary 170 6 Procedures 182 6.1 Introduction 183 6.2 Modules, Classes and Procedures 183 6.3 Sub Procedures 185 6.4 Function Procedures 188 6.5 Methods 190 6.6 Argument Promotion 195 6.7 Option Strict and Data-Type Conversions 196 6.8 Value Types and Reference Types 198 6.9 Passing Arguments: Pass-by-Value vs. Pass-by-Reference 200 6.10 Duration of Identifiers 202 6.11 Scope Rules 203 6.12 Random-Number Generation 206 6.13 Example: Game of Chance 213 6.14 Recursion 218 6.15 Example Using Recursion: Fibonacci Series 221 6.16 Recursion vs. Iteration 225 6.17 Procedure Overloading and Optional Arguments 226 6.17.1 Procedure Overloading 226 6.17.2 Optional Arguments 228 6.18 Modules 231 7 Arrays 245 7.1 Introduction 246 7.2 Arrays 246 7.3 Declaring and Allocating Arrays 248 7.4 Examples Using Arrays 249 7.4.1 Allocating an Array 250 7.4.2 Initializing the Values in an Array 251 7.4.3 Summing the Elements of an Array 252 7.4.4 Using Arrays to Analyze Survey Results 253 7.4.5 Using Histograms to Display Array Data Graphically 256 7.5 Passing Arrays to Procedures 260 7.6 Passing Arrays: ByVal vs. ByRef 264 7.7 Sorting Arrays 268 7.8 Searching Arrays: Linear Search and Binary Search 272 7.8.1 Searching an Array with Linear Search 272 7.8.2 Searching a Sorted Array with Binary Search 275 7.9 Multidimensional Rectangular and Jagged Arrays 279 X 7.10 Variable-Length Parameter Lists 287 7.11 For Each/Next Repetition Structure 288 8 Object-Based Programming 296 8.1 Introduction 297 8.2 Implementing a Time Abstract Data Type with a Class 298 8.3 Class Scope 306 8.4 Controlling Access to Members 306 8.5 Initializing Class Objects: Constructors 308 8.6 Using Overloaded Constructors 308 8.7 Properties 314 8.8 Composition: Objects as Instance Variables of Other Classes 321 8.9 Using the Me Reference 324 8.10 Garbage Collection 326 8.11 Shared Class Members 327 8.12 Const and ReadOnly Members 331 8.13 Data Abstraction and Information Hiding 334 8.14 Software Reusability 335 8.15 Namespaces and Assemblies 336 8.16 Class View and Object Browser 340 9 Object-Oriented Programming: Inheritance 349 9.1 Introduction 350 9.2 Base Classes and Derived Classes 351 9.3 Protected and Friend Members 354 9.4 Relationship between Base Classes and Derived Classes 354 9.5 Case Study: Three-Level Inheritance Hierarchy 372 9.6 Constructors and Finalizers in Derived Classes 376 9.7 Software Engineering with Inheritance 382 10 Object-Oriented Programming: Polymorphism 388 10.1 Introduction 389 10.2 Derived-Class-Object to Base-Class-Object Conversion 389 10.3 Type Fields and Select Case Statements 396 10.4 Polymorphism Examples 397 10.5 Abstract Classes and Methods 398 10.6 Case Study: Inheriting Interface and Implementation 400 10.7 NotInheritable Classes and NotOverridable Methods 408 10.8 Case Study: Payroll System Using Polymorphism 409 10.9 Case Study: Creating and Using Interfaces 419 10.10 Delegates 432 11 Exception Handling 441 11.1 Introduction 442 11.2 Exception Handling Overview 443 11.3 Example: DivideByZeroException 446 11.4 .NET Exception Hierarchy 450 XI 11.5 Finally Block 452 11.6 Exception Properties 459 11.7 Programmer-Defined Exception Classes 464 11.8 Handling Overflows 468 12 Graphical User Interface Concepts: Part 1 475 12.1 Introduction 476 12.2 Windows Forms 478 12.3 Event-Handling Model 480 12.4 Control Properties and Layout 487 12.5 Labels, TextBoxes and Buttons491 12.6 GroupBoxes and Panels494 12.7 CheckBoxes and RadioButtons497 12.8 PictureBoxes 508 12.9 Mouse-Event Handling 510 12.10 Keyboard-Event Handling 513 13 Graphical User Interfaces Concepts: Part 2 523 13.1 Introduction 524 13.2 Menus 524 13.3 LinkLabels534 13.4 ListBoxes and CheckedListBoxes 538 13.4.1 ListBoxes 540 13.4.2 CheckedListBoxes 542 13.5 ComboBoxes 545 13.6 TreeViews550 13.7 ListViews555 13.8 Tab Control 562 13.9 Multiple-Document-Interface (MDI) Windows 567 13.10 Visual Inheritance 576 13.11 User-Defined Controls 580 14 Multithreading 592 14.1 Introduction 593 14.2 Thread States: Life Cycle of a Thread 595 14.3 Thread Priorities and Thread Scheduling 596 14.4 Thread Synchronization and Class Monitor 601 14.5 Producer/Consumer Relationship without Thread Synchronization 603 14.6 Producer/Consumer Relationship with Thread Synchronization 609 14.7 Producer/Consumer Relationship: Circular Buffer 618 15 Strings, Characters and Regular Expressions 633 15.1 Introduction 634 15.2 Fundamentals of Characters and Strings 634 15.3 String Constructors 635 15.4 String Length and Chars Properties, and CopyTo Method 637 15.5 Comparing Strings639 XII 15.6 String Method GetHashCode 643 15.7 Locating Characters and Substrings in Strings644 15.8 Extracting Substrings from Strings647 15.9 Concatenating Strings648 15.10 Miscellaneous String Methods 649 15.11 Class StringBuilder 651 15.12 StringBuilder Indexer, Length and Capacity Properties, and EnsureCapacity Method 652 15.13 StringBuilder Append and AppendFormat Methods 654 15.14 StringBuilder Insert, Remove and Replace Methods 657 15.15 Char Methods 660 15.16 Card Shuffling and Dealing Simulation 663 15.17 Regular Expressions and Class Regex 667 16 Graphics and Multimedia 683 16.1 Introduction 684 16.2 Graphics Contexts and Graphics Objects 686 16.3 Color Control 687 16.4 Font Control 694 16.5 Drawing Lines, Rectangles and Ovals 699 16.6 Drawing Arcs 702 16.7 Drawing Polygons and Polylines 705 16.8 Advanced Graphics Capabilities 709 16.9 Introduction to Multimedia 714 16.10 Loading, Displaying and Scaling Images 714 16.11 Animating a Series of Images 716 16.12 Windows Media Player 729 16.13 Microsoft Agent 731 17 Files and Streams 752 17.1 Introduction 753 17.2 Data Hierarchy 753 17.3 Files and Streams 755 17.4 Classes File and Directory 757 17.5 Creating a Sequential-Access File 767 17.6 Reading Data from a Sequential-Access File 778 17.7 Random-Access Files 789 17.8 Creating a Random-Access File 794 17.9 Writing Data Randomly to a Random-Access File 797 17.10 Reading Data Sequentially from a Random-Access File 802 17.11 Case Study: A Transaction-Processing Program 807 18 Extensible Markup Language (XML) 833 18.1 Introduction 834 18.2 XML Documents 834 18.3 XML Namespaces 839 18.4 Document Object Model (DOM) 842 XIII 18.5 Document Type Definitions (DTDs), Schemas and Validation 860 18.5.1 Document Type Definitions 861 18.5.2 Microsoft XML Schemas 865 18.6 Extensible Stylesheet Language and XslTransform 870 18.7 Microsoft BizTalk™ 877 18.8 Internet and World Wide Web Resources 880 19 Database, SQL and ADO .NET 887 19.1 Introduction 888 19.2 Relational Database Model 889 19.3 Relational Database Overview: Books Database 890 19.4 Structured Query Language (SQL) 896 19.4.1 Basic SELECT Query 897 19.4.2 WHERE Clause 898 19.4.3 ORDER BY Clause 901 19.4.4 Merging Data from Multiple Tables: INNER JOIN 903 19.4.5 Joining Data from Tables Authors, AuthorISBN, Titles and Publishers 906 19.4.6 INSERT Statement 909 19.4.7 UPDATE Statement 910 19.4.8 DELETE Statement 911 19.5 ADO .NET Object Model 912 19.6 Programming with ADO .NET: Extracting Information from a DBMS 913 19.6.1 Connecting to and Querying an Access Data Source 913 19.6.2 Querying the Books Database 921 19.7 Programming with ADO .NET: Modifying a DBMS 923 19.8 Reading and Writing XML Files 932 20 ASP .NET, Web Forms and Web Controls 941 20.1 Introduction 942 20.2 Simple HTTP Transaction 943 20.3 System Architecture 945 20.4 Creating and Running a Simple Web-Form Example 946 20.5 Web Controls 958 20.5.1 Text and Graphics Controls 958 20.5.2 AdRotator Control 964 20.5.3 Validation Controls 969 20.6 Session Tracking 979 20.6.1 Cookies 980 20.6.2 Session Tracking with HttpSessionState 989 20.7 Case Study: Online Guest book 998 20.8 Case Study: Connecting to a Database in ASP .NET 1004 20.9 Tracing 1019 20.10 Internet and World Wide Web Resources 1021 21 ASP .NET and Web Services 1030 21.1 Introduction 1031 XIV 21.2 Web Services 1032 21.3 Simple Object Access Protocol (SOAP) and Web Services 1036 21.4 Publishing and Consuming Web Services 1037 21.5 Session Tracking in Web Services 1053 21.6 Using Web Forms and Web Services 1066 21.7 Case Study: Temperature Information Application 1072 21.8 User-Defined Types in Web Services 1081 21.9 Internet and World Wide Web Resources 1091 22 Networking: Streams-Based Sockets and Datagrams 1096 22.1 Introduction 1097 22.2 Establishing a Simple Server (Using Stream Sockets) 1098 22.3 Establishing a Simple Client (Using Stream Sockets) 1100 22.4 Client/Server Interaction via Stream-Socket Connections 1101 22.5 Connectionless Client/Server Interaction via Datagrams 1110 22.6 Client/Server Tic-Tac-Toe Using a Multithreaded Server 1116 23 Data Structures and Collections 1136 23.1 Introduction 1137 23.2 Self-Referential Classes 1137 23.3 Linked Lists 1139 23.4 Stacks 1152 23.5 Queues 1156 23.6 Trees 1160 23.6.1 Binary Search Tree of Integer Values 1161 23.6.2 Binary Search Tree of IComparable Objects 1168 23.7 Collection Classes 1175 23.7.1 Class Array 1176 23.7.2 Class ArrayList 1179 23.7.3 Class Stack 1185 23.7.4 Class Hashtable 1189 24 Accessibility 1203 24.1 Introduction 1204 24.2 Regulations and Resources 1205 24.3 Web Accessibility Initiative 1207 24.4 Providing Alternatives for Images 1208 24.5 Maximizing Readability by Focusing on Structure 1209 24.6 Accessibility in Visual Studio .NET 1209 24.6.1 Enlarging Toolbar Icons 1210 24.6.2 Enlarging the Text 1211 24.6.3 Modifying the Toolbox 1212 24.6.4 Modifying the Keyboard 1213 24.6.5 Rearranging Windows 1214 24.7 Accessibility in Visual Basic 1215 24.8 Accessibility in XHTML Tables 1221 XV 24.9 Accessibility in XHTML Frames 1225 24.10 Accessibility in XML 1226 24.11 Using Voice Synthesis and Recognition with VoiceXML™ 1226 24.12 CallXML™ 1233 24.13 JAWS® for Windows 1240 24.14 Other Accessibility Tools 1240 24.15 Accessibility in Microsoft® Windows® 2000 1241 24.15.1 Tools for People with Visual Impairments 1243 24.15.2 Tools for People with Hearing Impairments 1246 24.15.3 Tools for Users Who Have Difficulty Using the Keyboard 1247 24.15.4 Microsoft Narrator 1251 24.15.5 Microsoft On-Screen Keyboard 1252 24.15.6 Accessibility Features in Microsoft Internet Explorer 5.5 1253 24.16 Internet and World Wide Web Resources 1255 A Operator Precedence Chart 1264 B Number Systems (on CD) 1266 B.1 Introduction 1267 B.2 Abbreviating Binary Numbers as Octal Numbers and Hexadecimal Numbers 1270 B.3 Converting Octal Numbers and Hexadecimal Numbers to Binary Numbers 1272 B.4 Converting from Binary, Octal or Hexadecimal to Decimal 1272 B.5 Converting from Decimal to Binary, Octal, or Hexadecimal 1273 B.6 Negative Binary Numbers: Two’s Complement Notation 1274 C Career Opportunities (on CD) 1280 C.1 Introduction 1281 C.2 Resources for the Job Seeker 1282 C.3 Online Opportunities for Employers 1283 C.3.1 Posting Jobs Online 1285 C.3.2 Problems with Recruiting on the Web 1287 C.3.3 Diversity in the Workplace 1287 C.4 Recruiting Services 1288 C.5 Career Sites 1289 C.5.1 Comprehensive Career Sites 1289 C.5.2 Technical Positions 1290 C.5.3 Wireless Positions 1290 C.5.4 Contracting Online 1291 C.5.5 Executive Positions 1292 C.5.6 Students and Young Professionals 1293 C.5.7 Other Online Career Services 1293 C.6 Internet and World Wide Web Resources 1294 D Visual Studio .NET Debugger 1302 D.1 Introduction 1303 D.2 Breakpoints 1304 D.3 Examining Data 1306 XVI D.4 Program Control 1308 D.5 Additional Procedure Debugging Capabilities 1312 D.6 Additional Class Debugging Capabilities 1314 E ASCII Character Set 1319 F Unicode ® (on CD) 1320 F.1 Introduction 1321 F.2 Unicode Transformation Formats 1322 F.3 Characters and Glyphs 1323 F.4 Advantages/Disadvantages of Unicode 1324 F.5 Unicode Consortium’s Web Site 1324 F.6 Using Unicode 1325 F.7 Character Ranges 1327 G COM Integration (on CD) 1332 G.1 Introduction 1332 G.2 ActiveX Integration 1333 G.3 DLL Integration 1337 G.4 Internet and World Wide Web Resources 1341 H Introduction to HyperText Markup Language 4: Part 1 (on CD) 1344 H.1 Introduction 1345 H.2 Markup Languages 1345 H.3 Editing HTML 1346 H.4 Common Elements 1346 H.5 Headers 1349 H.6 Linking 1350 H.7 Images 1352 H.8 Special Characters and More Line Breaks 1356 H.9 Unordered Lists 1358 H.10 Nested and Ordered Lists 1359 H.11 Internet and World Wide Web Resources 1362 I Introduction to HyperText Markup Language 4: Part 2 (on CD) 1367 I.1 Introduction 1368 I.2 Basic HTML Tables 1368 I.3 Intermediate HTML Tables and Formatting 1370 I.4 Basic HTML Forms 1373 I.5 More Complex HTML Forms 1376 I.6 Internal Linking 1383 I.7 Creating and Using Image Maps 1386 I.8 <meta> Tags 1388 I.9 frameset Element 1390 [...]... Welcome to Visual Basic NET and the exciting world of Windows, Internet and WorldWide-Web programming with Visual Studio and the NET platform! This book is the first in our new NET How to Program series, which presents various leading-edge computing technologies in the context of the NET platform Visual Basic NET provides the features that are most important to programmers, such as object-oriented programming,... Page in Visual Studio NET New Project dialog Design view of Visual Studio NET IDE Visual Studio NET IDE menu bar Summary of Visual Studio NET IDE menus IDE Toolbar Tool tip demonstration Toolbar icons for three Visual Studio NET IDE windows Auto-hide feature demonstration Solution Explorer with an open solution Toolbox window Properties window Help menu commands Dynamic Help window Simple program executing... Although Visual Basic NET is a significant departure from Visual Basic 6.0, forcing programmers to revamp their skills, programmers will be motivated to do so because of the powerful range of capabilities that Microsoft is offering in its NET initiative A World of Object Orientation When we wrote the first edition of Visual Basic 6 How to Program, universities were still emphasizing procedural programming... principles of computer programming and of the Visual Basic NET language, including control structures, object-oriented programming, Visual Basic NET class libraries, graphical-user-interface concepts, event-driven programming and more After mastering the material in this book, students will be well-prepared to program in Visual Basic NET and to employ the capabilities of the NET platform Preface XLII... procedural programming with object-oriented programming—something that C++ lets programmers do Many instructors now are emphasizing a pure object-oriented programming approach This book—the second edition of Visual Basic NET How to Program and the first text in our NET series—takes a predominantly object-oriented approach because of the enhanced object orientation provided in Visual Basic NET Focus... than requiring developers to learn a new programming language, programmers can contribute to the same software project, but write code using any (or several) of the NET languages (such as Visual Basic NET, Visual C++ NET, C# and others) with which they are most competent In addition to providing language independence, NET extends program portability by enabling NET applications to reside on, and communicate... help programmers find and correct logic errors in program code Visual Studio NET contains a powerful debugging tool that allows programmers to analyze their program line-byline as the program executes In Appendix D, Visual Studio NET Debugger, we Preface XL explain how to use key debugger features, such as setting breakpoints and “watches,” stepping into and out of procedures, and examining the procedure... programmers to build Web documents that respond to client requests To enable interactive Web pages, server-side programs process information users input into HTML forms ASP NET is a significant departure Preface XXXIX from previous versions of ASP, allowing developers to program Web-based applications using the powerful object-oriented languages of NET ASP NET also provides enhanced visual programming... registration Customize Toolbox dialog with an ActiveX control selected IDE’s toolbox and LabelScrollbar properties ActiveX COM control integration in Visual Basic NET Add Reference dialog DLL Selection COM DLL component in Visual Basic. NET 1319 1323 1323 1326 1328 1332 1333 1334 1335 1335 1338 1339 H Introduction to HyperText Markup Language 4: Part 1 (on CD) H.1 H.2 H.3 H.4 H.5 H.6 H.7 H.8 H.9 Basic HTML... leadingedge language, Visual Basic NET, and a leading-edge programming paradigm (object-oriented programming) that will be immediately useful to them as they enter a business world in which the Internet and the World Wide Web have a massive prominence This increases their enthusiasm for the material—which is essential when you consider that there is much more to learn in a Visual Basic NET course now that . Internet and Visual Basic .NET 1.1 .NET Languages. 19 2 Introduction to the Visual Studio .NET IDE 2.1 Start Page in Visual Studio .NET. 35 2.2 New Project dialog. 36 2.3 Design view of Visual. Studio .NET IDE. 37 2.4 Visual Studio .NET IDE menu bar. 38 2.5 Summary of Visual Studio .NET IDE menus. 38 2.6 IDE Toolbar. 38 2.7 Tool tip demonstration. 39 2.8 Toolbar icons for three Visual. 18 1.18 Tour of the Book 20 1.19 Internet and World Wide Web Resources 29 VIII 2 Introduction to the Visual Studio .NET IDE 33 2.1 Introduction 34 2.2 Overview of the Visual Studio .NET IDE 34 2.3

Ngày đăng: 17/04/2014, 09:18

TỪ KHÓA LIÊN QUAN