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

Prentice hall an introduction to programming using visual basic 2005 6th edition mar 2006 ISBN 0130306541

1,3K 118 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.339
Dung lượng 11,9 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Since its introduction in 1991, Visual Basic has been the most widely used programming language in the world.. Likewise, students learning their first programming language will find Visu

Trang 1

Publisher : Prentice Hall Pub Date : March 03, 2006 Print ISBN-10 : 0-13-030654-1 Print ISBN-13 : 978-0-13-030654-8 eText ISBN-10 : 0-13-186104-2 eText ISBN-13 : 978-0-13-186104-6

Pages : 752

Based on the newest version of Microsoft's VB NET, this revision

of Schneider's best-selling text is designed for students with noprior computer programming experience The author uses VisualBasic NET to explore the fundamentals of programming, building

a strong foundation that will give students a sustainableunderstanding of programming A broad range of examples, casestudies, exercises, and programming projects give studentssignificant hands-on experience A "tried and true" text, this bookhas been consistently praised by both students and instructors

Trang 2

Publisher : Prentice Hall Pub Date : March 03, 2006 Print ISBN-10 : 0-13-030654-1 Print ISBN-13 : 978-0-13-030654-8 eText ISBN-10 : 0-13-186104-2 eText ISBN-13 : 978-0-13-186104-6

Trang 5

Communicating between Arguments and Parameters 633 Stepping through Programs Containing Selection Structures:

Stepping through a Program Containing a Do Loop: Chapter 6 635 Answers: To Selected Odd-Numbered Exercises 637

Trang 6

Chapter 10 714

Index

Trang 7

[Page iv]

Library of Congress Cataloging-in-Publication Data on File

Manufacturing Manager: Alexis Heydt-Long

Manufacturing Buyer: Lisa McDowell

Marketing Manager: Robin O'Brien

© 2006, 2003, 1999, 1998, 1997, 1995 Pearson Education, Inc Pearson Prentice Hall

Pearson Education, Inc.

Upper Saddle River, NJ 07458

All rights reserved No part of this book may be reproduced, in any form or by any means, without permission in writing from the publisher.

Pearson Prentice Hall™ is a trademark of Pearson Education, Inc.

Trang 8

The author and publisher of this book have used their best efforts in preparing this book These efforts include the

development, research, and testing of the theories and

programs to determine their effectiveness The author and publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation contained

in this book The author and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.

Trang 9

[Page xi]

Trang 10

Since its introduction in 1991, Visual Basic has been the most widely used programming language in the world The latest

incarnation of Visual Basic is called Visual Basic 2005 Visual Basic programmers are enthusiastically embracing the new

features of the language Likewise, students learning their first programming language will find Visual Basic 2005 the ideal tool

to understand the development of computer programs.

My objectives when writing this text were as follows:

1 To develop focused chapters Rather than covering many

topics superficially, I concentrate on important subjects and cover them thoroughly.

2 To use examples and exercises that students can appreciate

and with which they can relate, and feel comfortable I

frequently use real data Examples do not have so many embellishments that students are distracted from the

programming techniques illustrated.

3 To produce compactly written text that students will find

both readable and informative The main points of each

topic are discussed first, and then the peripheral details are presented as comments.

4 To teach good programming practices that are in step with

modern programming methodology Problem-solving

techniques and structured programming are discussed early and used throughout the book The style follows object- oriented programming principles.

5 To provide insights into the major applications of

computers.

Trang 11

Unique and Distinguishing Features

Exercises for Most Sections

Each section that teaches programming has an exercise set The exercises both reinforce the understanding of the key ideas

of the section and challenge the student to explore applications Most of the exercise sets require the student to trace programs, find errors, and write programs The answers to all the odd-

the end of the text.

Practice Problems

Practice Problems are carefully selected exercises located at the end of a section, just before the exercise set Complete

solutions are given following the exercise set The practice

problems often focus on points that are potentially confusing or are best appreciated after the student has worked on them The reader should seriously attempt the practice problems and

Trang 12

Each of the four case studies focuses on an important

programming application The problems are analyzed and the programs are developed with top-down charts and pseudocode The programs can be found on the companion website at

Trang 13

so that the presentation of procedures easily can be postponed until decision and repetition structures have been presented In

Chapters 5 and 6 (and Sections 7.1 and 7.2 ), all programs

using procedures appear at the ends of sections and can be deferred or omitted.

Arrays

Arrays are introduced gently in two sections The first section presents the basic definitions and avoids procedures The

second section presents the techniques for manipulating arrays and shows how to pass arrays to procedures.

NetSearch terms, Destination Links, online study guide with additional exercises and learning resources for students.

Trang 14

4 A section on graphics has been added

5 Nine programming projects have been added.

Trang 15

[Page xiii]

Trang 16

Many talented instructors, students, and programmers provided helpful comments and constructive suggestions during the

preparation of this text For their contributions to the quality of the first four editions of the book I extend my gratitude to A Abonomah, University of Akron; Timothy Babbitt, Rochester Institute of Technology; William Barnett, Northwestern State University; Sherry Barriclow, Grand Valley State University;

Robert Berman, Wayne State University; William Burrows,

University of Washington; David Chao, San Francisco State

University; Christopher Chisolm, University of Nebraska,

Omaha; Robert Coil, Cincinnati State Technical and Community College; Gary Cornell, University of Connecticut; Ronit Dancis; John DaPonte, Southern Connecticut State University; Ward Deutschman, Briarcliff; Ralph Duffy, North Seattle Community College; Charles Fairchild; Pat Fenton, West Valley College;

David Fichbohm, Golden Gate University; Robert Fritz, American River College; Matthew Goddard, New Hampshire Technical

College; Mickie Goodro, Casper College; Wade T Graves,

Grayson Community College; Christine Griffin; Gary Haw, MIPS Software Development Inc.; Shelly Hawkins, Microsoft; Tom Janicki, Kent State University; Dana Johnson, North Dakota

State University; Dan Joseph, Rochester Institute of

Technology; Del Kimber, Clemson University; Wanda Kunkle, Rowan College; Paul Lecoq, San Francisco Community College; David Leitch, Devry Institute; David Letcher, The College of New Jersey; Kieran Mathieson, Oakland University; Charlie Miri,

Delaware Tech; George Nezlek, DePaul University; Ron Notes, Hebrew Academy of Greater Washington; Mike Paul, Berry

University; T S Pennington, Maple Woods Community College; Arland Richmond, Computer Learning Center; David Rosser, Essex County College; Arturo Salazar, San Francisco State;

Susanne Peterson, Microsoft; Janie Schwark, Microsoft; Mike Talber, Portland Community College; Steve Turek, Devry

Trang 17

Washington State University; Randy Weinberg, St Cloud State University; Laurie Werner, Miami University; Melinda, White, Santa Fe Community College; Ronald Williams, Central

Piedmont Community College; Amit Kalani, CIStems Solutions LLC; Priti Kalani, MobiEcast Corporation; Chris Panell, Heald

managing editor.

I also express my thanks to Marc Leager, a talented

programmer, who helped with the development of the book, and provided valuable insights and careful proofreading I am

grateful to Shaun Szot for his valuable proofreading Production editor, Rose Kernan, and compositor Rebecca Evans did a

fantastic job producing the book and keeping it on schedule.

I extend special thanks to my editor Tracy Dunkelberger Her

Trang 18

ideas and enthusiasm helped immensely with the preparation of the book.

Trang 19

[Page xv]

Trang 20

of the TXT files needed for the exercises, all databases needed for the exercises, and several BMP (picture) files All these files are contained in the folder "Programs" in the subfolders "Ch03",

"Ch04", "Ch05", and so on Each chapter file contains a

subfolder named "Text files for Exercises" which contains TXT files needed for that chapter's exercises The folder "Ch09" has

a subfolder named "Pictures" that contains the BMP files The folder "Ch10" has a subfolder named "MajorDatabases"

containing all the databases needed for the exercises.

Each program is contained in a folder with a name in the for

chaptersectionnumber For instance, the program in Chapter 3,

Section 5, Example 2 is contained in the folder "3-5-2" Many of the programs make use of a TXT file in the subfolder of the

Trang 21

Students can access additional Visual Basic 2005 resources via helpful NetSearch Terms and Destination Links located on the companion website.

[Page xv (continued)]

Instructors

Essential instructor resources including solutions to the

exercises, PowerPoint lecture slides, all the example programs and data files used by students throughout the book, and

multiple-choice and true/false questions are provided on the Instructor Resource Center Contact your local Prentice Hall Sales Representative to gain access to the IRC.

Trang 22

[Page xvi]

Trang 23

Condensed Course

This book provides more than enough material for a complete semester course The topics must be trimmed for courses lasting considerably less than a full semester The following syllabus provides one possible way to present an abbreviated introduction to programming.

Trang 24

9 Additional Controls and Objects

9.1 List Boxes, Combo Boxes, and the File-Opening Control

9.2 Seven Elementary Controls

Trang 25

[Page 1]

Trang 26

Chapter 1 An Introduction to Computers and Visual Basic 2005

Trang 27

1930s 1940s 1950s 1960s 1970s 1980s 1990s

Trang 28

1.1 An Introduction to Computers

An Introduction to Programming Using Visual Basic 2005 is a

book about problem solving using computers The programming language used is Visual Basic 2005 (hereafter shortened to

Visual Basic), but the principles taught apply to many modern programming languages The examples and exercises present a sampling of the ways that computers are used in society.

Computers are so common today that you certainly have heard some of the terminology applied to them Here are some

Trang 29

Information processed by the computer can be displayed on the monitor, printed on the printer, or recorded on a disk drive.

Question: What are some uses of computers in our society?

Answer: The dramatic decrease in the cost of hardware and

software technology has made computers widely available to consumers and corporations alike Whenever we make a phone call, a computer determines how to route the call and calculates the cost of the call Banks store all customer transactions on computers and process these transactions to revise the balance for each customer Airlines record all reservations with

computers This information, which is stored in a database, can

be accessed to determine the status of any flight NASA uses computers to calculate the trajectories of satellites Business analysts use computers to create pie and bar charts that give visual impact to data With the Internet connecting millions of home computers, families and friends can exchange messages, information, and pictures Consumers can shop from their PCs Virtually no aspect of modern life is untouched by computer technology.

Trang 30

engineering courses Personal financial transactions, such as bank deposits and loans, can be recorded, organized, and

It consists of instructions to which people can relate, such as Click, If, and Do.

Question: How do we get computers to perform complicated

tasks?

Answer: Tasks are broken down into a sequence of instructions

that can be expressed in a computer language (This text uses the language Visual Basic.) This sequence of instructions is

called a program Programs can range in size from two or three

instructions to millions of instructions Instructions are typed on the keyboard, or read in from a file on a disk, and stored in the computer's memory The process of executing the instructions

is called running the program.

Question: What is a server?

Answer: Whether a computer is a server depends on how it is

being used A computer that is only used by one person is a

Trang 31

as files, printers, or Internet access to other computers Since a server needs to be continuously available to other computers, additional components are usually added to it to increase its reliability in the event of a power failure or other unexpected event.

a disk drive, or be provided by the computer operator in

response to requests made by the computer while the program

is running The processing of the input data occurs inside the computer and can take from a fraction of a second to many

hours The output data are either displayed on the monitor,

printed on the printer, or recorded on a disk As a simple

example, consider a program that computes sales tax An item

of input data is the cost of the thing purchased The processing consists of multiplying the cost by a certain percentage An item

are referred to as software.

[Page 4]

Question: What are the meanings of the terms "programmer"

Trang 32

Answer: A programmer is a person who solves problems by

writing programs on a computer After analyzing the problem and developing a plan for solving it, he or she writes and tests the program that instructs the computer how to carry out the plan The program might be run many times, either by the

Question: How did Visual Basic 2005 evolve?

Answer: In the early 1960s, two mathematics professors at

Dartmouth College developed BASIC to provide their students with an easily learned language that could tackle complicated programming projects As the popularity of BASIC grew,

refinements were introduced that permitted structured

programming, which increases the reliability of programs Visual Basic 1.0 is a version of BASIC developed in 1991 by the

Microsoft Corporation to allow easy, visual-oriented

development of Windows applications Visual Basic 2005 is a language similar to the original Visual Basic, but more powerful.

Trang 33

It is targeted for what is known as the NET run time, which is a program that executes Visual Basic 2005 as well as programs from other languages that are targeted for the NET run time This will ultimately allow programs written in Visual Basic to be run on devices other than computers, such as cell phones and handheld devices Other features of Visual Basic include full object-oriented programming capabilities and the development

of Web services Object-oriented programming is discussed in

Chapter 11 The techniques presented in this book can be

applied to the development of Web services.

Trang 34

1.2 Using Windows

Programs such as Visual Basic, which are designed for Microsoft Windows, are easy to useonce you learn a little jargon and a few basic techniques This section explains the jargon, giving you enough understanding of Windows to get you started in Visual Basic Although Windows may seem intimidating if you've never used it before, you need to learn only a few basic

techniques, which are covered in this section.

[Page 5]

Mouse Pointers

When you use Windows, think of yourself as the conductor and Windows as the orchestra The conductor in an orchestra points

to various members and does something with his or her baton; then the orchestra members respond in certain ways For a

Windows user, the baton is called the pointing device; most often it is a mouse As you move the mouse across your desk,

a pointer moves along the screen in sync with your movements Two basic types of mouse pointers you will see in Windows are

The hourglass mouse pointer pops up whenever Windows is

saying "Wait a minute; I'm thinking." This pointer still moves

Trang 35

to do anything until it finishes what it's doing and the mouse pointer no longer resembles an hourglass (Sometimes you can press the Esc key to tell Windows to stop what it is doing.)

Note: The mouse pointer can take on many other shapes,

depending on which application you are using and what task you are performing For instance, when entering text in a word processor or Visual Basic, the mouse pointer appears as a thin, large, uppercase I (referred to as an I-beam).

Mouse Actions

After you move the (arrow) pointer to a place where you want something to happen, you need to do something with the

1 move the mouse pointer until it is at the object you are

supposed to click on and

2 press and release the left mouse button.

An example of a sentence using this jargon might be "Click on the button marked Yes." You also will see sentences that begin

Trang 36

"Click inside the " This means to move the mouse pointer until it is inside the boundaries of the object, and then click.

Double-clicking means clicking the left mouse button twice in

quick succession (that is, pressing it, releasing it, pressing it, and releasing it again quickly so that Windows doesn't think you single-clicked twice) Whenever a sentence begins "Double-click

Note: An important Windows convention is that clicking selects

an object so you can give Windows or the document further directions about it, but double-clicking tells Windows to perform

a default operation For example, double-clicking on a folder will open that folder.

Trang 37

pressing Ctrl + Esc (In the notation "key1 + key2", the plus sign (+) instructs you to hold down key1 and then press key2 There are many useful key combinations of this type.)

Windows and Its Little Windows

Windows gets its name from the way it organizes your screen into rectangular regions When you run a program, the program runs inside a bordered rectangular box Unfortunately Windows jargon calls all of these windows, so there's only a lowercase

"w" to distinguish them from the operating system called

Windows.

When Windows' attention is focused on a specific window, the Title bar at the top of the window is blue and the window is said

to be active (Inactive windows have a gray Title bar.) The

active window is the only one that can be affected by your

actions An example of a sentence you might see is "Make the window active." This means that if the Title bar of the window is gray, click inside the window At this point, the active window will be responsive to your actions.

Trang 38

We will explore the Windows application Notepad to illustrate the Windows environment Notepad is used extensively in this text to create text files for programs Most of the concepts

[Page 7]

Figure 1.1 The Notepad window.

[View full size image]

Trang 39

type will appear at the cursor The Notepad window is divided into four parts The part containing the cursor is called the

Work area It is the largest and most important part of the

window because documents are typed into this window.

The Title bar at the top of the screen holds the name of the

document currently being written Until the document is given a name, the document is called "Untitled." The three buttons on the right side of the title bar can be used to maximize,

minimize, or close the window You can click on the Maximize button to make the Notepad window fill the entire screen, click

on the Minimize button to change the Notepad window into a button on the taskbar, or click on the Close button to exit

Notepad As long as a window isn't maximized or minimized, you can usually move it around the screen by dragging its title bar (Recall that this means to move the mouse pointer until it

is in the title bar, hold down the left mouse button, move the mouse until the window is where you want it to be, and then release the mouse button.)

Trang 40

instructions in Visual Basic that are longer than one screen You can use the mouse to scroll through your instructions with small

steps or giant steps A Vertical scroll bar lets you move from the top to the bottom of the window; a Horizontal scroll bar

of the channel, you'll scroll to approximately the middle of your document.

The Menu bar just below the Title bar is used to call up menus,

or lists of tasks Several of these tasks are described in this section.

Documents are created from the keyboard in much the same

Ngày đăng: 26/03/2019, 16:07

TỪ KHÓA LIÊN QUAN