Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visual Basic 2010 How to Program © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

Similar presentations


Presentation on theme: "Visual Basic 2010 How to Program © 1992-2010 by Pearson Education, Inc. All Rights Reserved."— Presentation transcript:

1 Visual Basic 2010 How to Program © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

2

3

4  Welcome to Visual Basic 2010.  Computers process data, using sets of instructions called computer programs.  These programs guide computers through orderly sets of calculations and other actions that are specified by people known as computer programmers.  Today’s personal computers can perform billions of these calculations and actions per second. A person operating a desk calculator might require a lifetime to complete the same amount of work!  Today’s fastest supercomputers work so quickly that they can perform the equivalent of 150,000 actions and calculations per second for every person on the planet! © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

5  A computer consists of various devices referred to as hardware (for example, the keyboard, screen, mouse, hard drive, memory, DVDs and processing units).  The programs that run on a computer are referred to as software (for example, applications such as word processors, payroll systems, spreadsheets, e-mail systems, games, etc.).  Object-oriented programming (which models real-world objects with software counterparts), can greatly enhance your productivity.  The core of this book emphasizes achieving program clarity through the proven techniques of object-oriented programming (OOP) and event-driven programming. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

6  Regardless of differences in physical appearance, virtually every computer may be envisioned as divided into various logical units or sections: © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

7 ◦ Input unit. This “receiving” section obtains information (data and computer programs) from input devices and places it at the disposal of the other units so that it can be processed. Most information is entered into computers through keyboards and mouse devices. Information also can be entered in many other ways, including by speaking to your computer, scanning images and barcodes, reading from secondary storage devices (like hard drives, CD drives, DVD drives and USB drives— also called “thumb drives”) and having your computer receive information from the Internet (such as when you download videos from YouTube™, e-books from Amazon, and the like). © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

8 ◦ Output unit. This “shipping” section takes information that the computer has processed and places it on various output devices to make it available for use outside the computer. Most information that is output from computers today is displayed on screens, printed on paper, played on audio players (such as Apple’s popular iPods), or used to control other devices. Computers also can output their information to networks, such as the Internet. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

9 ◦ Memory unit. This rapid-access, relatively low-capacity “warehouse” section retains information that has been entered through the input unit, making it immediately available for processing when needed. The memory unit also retains processed information until it can be placed on output devices by the output unit. Information in the memory unit is volatile— it’s typically lost when the computer’s power is turned off. The memory unit is often called either memory or primary memory. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

10 ◦ Arithmetic and logic unit (ALU). This “manufacturing” section performs calculations, such as addition, subtraction, multiplication and division. It also contains the decision mechanisms that allow the computer, for example, to compare two items from the memory unit to determine whether they’re equal. In today’s systems, the ALU is usually implemented as part of the next logical unit, the CPU. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

11 ◦ Central processing unit (CPU). This “administrative” section coordinates and supervises the operation of the other sections. The CPU tells the input unit when information should be read into the memory unit, tells the ALU when information from the memory unit should be used in calculations and tells the output unit when to send information from the memory unit to certain output devices. Many of today’s computers have multiple CPUs and, hence, can perform many operations simultaneously—such computers are called multiprocessors. A multi-core processor implements multiprocessing on a single integrated circuit chip—for example a dual-core processor has two CPUs and a quad-core processor has four CPUs. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

12 ◦ Secondary storage unit. This is the long-term, high-capacity “warehousing” section. Programs or data not actively being used by the other units normally are placed on secondary storage devices (for example, your hard drive) until they’re needed again, possibly hours, days, months or even years later. Therefore, information on secondary storage devices is said to be persistent—it is preserved even when the computer’s power is turned off. Secondary storage information takes much longer to access than information in primary memory, but the cost per unit of secondary storage is much less than that of primary memory. Examples of secondary storage devices include CDs, DVDs and flash drives (sometimes called memory sticks), which can hold hundreds of millions to billions of characters. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

13  In 1977, Apple Computer—creator of today’s popular Mac personal computers, iPod digital music players, iPhones and iPads —popularized personal computing.  In 1981, IBM, the world’s largest computer vendor, introduced the IBM Personal Computer, legitimizing personal computing in business, industry and government.  These computers were “stand-alone” units—people transported disks back and forth between computers to share information (creating a “sneakernet”).  These machines could be linked together in computer networks, sometimes over telephone lines and sometimes in local area networks (LANs) within an organization. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

14  This led to distributed computing, in which an organization’s computing is distributed over networks to the sites where the organization’s work is performed.  Information is shared across computer networks, where computers called servers offer a common data store and services that may be used by client computers throughout the network, hence the term client/server computing.  In Chapter 13, we’ll build Internet-based applications; we’ll talk about web servers (computers that distribute content over the web) and web clients (computers that request and receive the content offered up by web servers). © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

15  Every year or two, the computing power of computers has approximately doubled without any increase in price.  This often is called Moore’s Law, named after the person who first identified and explained the trend, Gordon Moore, co-founder of Intel—the company that manufactures the vast majority of the processors in today’s personal computers.  Moore’s Law is especially true in relation to the amount of memory that computers have for programs and data, the amount of secondary storage (such as disk storage) they have, and their processor speeds—the speeds at which computers execute their programs (that is, do their work). © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

16  In the mid-1980s, Microsoft developed the Windows operating system, consisting of a graphical user interface built on top of DOS (a personal computer operating system that users interacted with by typing commands).  The Windows operating system became incredibly popular after the 1993 release of Windows 3.1, whose successors, Windows 95 and Windows 98, virtually cornered the desktop operating systems market by the late 1990s.  These operating systems, which borrowed from many concepts (such as icons, menus and windows) popularized by early Apple Macintosh operating systems, enabled users to navigate multiple applications simultaneously. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

17  Microsoft entered the corporate operating systems market with the 1993 release of Windows NT.  Windows XP, was released in 2001 and combined Microsoft’s corporate and consumer operating system lines.  Windows Vista, released in 2007, offered the attractive Aero user interface, many enhancements and new applications.  A key focus of Windows Vista was enhanced security. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

18

19

20

21

22

23

24 Punch Card Machine

25 © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

26

27

28

29

30  Windows 7 is Microsoft’s latest operating system—its features include enhancements to the Aero user interface, faster startup times, further refinement of Vista’s security features, touch screen and multi-touch support, and more.  This book is intended for Windows XP, Windows Vista and Windows 7 users.  Windows is the world’s most widely used operating system. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

31  Although hundreds of computer languages are in use today, they can be divided into three general types: ◦ Machine languages ◦ Assembly languages ◦ High-level languages © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

32  Machine Languages ◦ A computer can directly understand only its own machine language, which is defined by the computer’s hardware design. ◦ Machine languages generally consist of streams of numbers (ultimately reduced to 1s and 0s) that instruct computers how to perform their most elementary operations. ◦ Only 1s and 0s are used in the binary number system. ◦ Machine-language programs are called binaries. ◦ Machine languages are machine dependent—a particular machine language can be used on only one type of computer. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

33  The following section of an early machine-language program, which adds overtime pay to base pay and stores the result in gross pay, demonstrates the incomprehensibility of machine language to humans:  +1300042774 +1400593419 +1200274027 © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

34  Assembly Languages ◦ As the popularity of computers increased, machine-language programming proved to be slow and error prone. ◦ Instead of using the strings of numbers that computers could directly understand, programmers began using English-like abbreviations (called mnemonics) to represent the computer’s basic operations. ◦ These abbreviations formed the basis of assembly languages. ◦ Translator programs called assemblers convert assembly- language programs to machine language at computer speeds. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

35  The following section of an assembly-language program also adds overtime pay to base pay and stores the result in gross pay, but the steps are clearer to humans than in the machine-language example:  LOAD BASEPAY ADD OVERPAY STORE GROSSPAY © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

36  High-Level Languages ◦ The speed at which programmers could write programs increased rapidly with the creation of assembly languages, but these languages still require many instructions to accomplish even simple tasks. ◦ To speed up the programming process, high-level languages (in which single program statements accomplish more substantial tasks) were developed. ◦ Translator programs called compilers convert high-level- language programs into machine language. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

37  High-level languages enable you to write instructions that look almost like everyday English and contain common mathematical notations.  For example, a payroll application written in a high- level language might contain a statement such as  grossPay = basePay + overTimePay  Visual Basic is one of the world’s most popular high- level programming languages. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

38  Visual Basic evolved from BASIC (Beginner’s All-purpose Symbolic Instruction Code), developed in the mid-1960s at Dartmouth College as a language for introducing novices to fundamental programming techniques.  When Bill Gates founded Microsoft Corporation in the 1970s, he implemented BASIC on several early personal computers.  In the late 1980s and the early 1990s, Microsoft developed its Windows graphical user interface (GUI)—the visual part of the operating system with which users interact. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

39  With the creation of the Windows GUI, the natural evolution of BASIC was to Visual Basic, introduced by Microsoft in 1991 to make programming Windows applications easier.  Until Visual Basic appeared, developing Microsoft Windows-based applications was a difficult process.  Visual Basic programs are created with the use of a collection of software tools called an Integrated Development Environment (IDE).  With Microsoft’s Visual Studio 2010 IDE, you can write, run, test and debug Visual Basic programs quickly. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

40  The latest versions of Visual Basic are fully object oriented.  Visual Basic is event driven —you’ll write programs that respond to user-initiated events such as mouse clicks, keystrokes and timer expirations.  It’s a visual programming language—in addition to writing program statements to build portions of your applications, you’ll also use Visual Studio’s graphical user interface to conveniently drag and drop predefined objects like buttons and textboxes into place on your screen, and label and resize them.  Visual Studio will write much of the GUI code for you. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

41  The C programming language was developed in the early 1970s.  C first gained widespread recognition as the development language of the UNIX operating system.  C is a hardware-independent language, and, with careful design, it is possible to write C programs that are portable to most computers. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

42  C++, developed in the early 1980s, provides several features that “spruce up” the C language, and, more importantly, capabilities for object-oriented programming (OOP).  Objects are reusable software components that model items in the real world.  A modular, object-oriented approach to design and implementation can make software development groups much more productive. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

43  The Objective-C programming language, also developed in the early 1980s, added capabilities for object-oriented programming (OOP) to the C programming language.  It eventually became the software development language for Apple’s Macintosh.  Its use has exploded as the app development language for Apple’s wildly popular iPod, iPhone and iPad consumer devices.  Objective-C has access to the Cocoa frameworks (powerful libraries of prebuilt components), enabling you to develop apps quickly. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

44  Microprocessors are having a profound impact in intelligent consumer electronic devices.  Recognizing this, Sun Microsystems in 1991 funded an internal corporate research project that resulted in the development of a C++-based language, which Sun eventually called Java.  As the World Wide Web exploded in popularity in 1993, Sun saw the possibility of using Java to add dynamic content (for example, interactivity, animations and the like) to web pages.  Sun announced the language in 1995.  This generated immediate interest in the business community because of the commercial potential of the web. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

45  Java is now used to develop large-scale enterprise applications, to enhance the functionality of web servers (the computers that provide the content we see in our web browsers), to provide applications for consumer devices (such as cell phones, pagers and personal digital assistants) and for many other purposes.  Visual Basic 2010 is similar in capability to Java.  In 2000, Microsoft announced the C# (pronounced “C- Sharp”) programming language—created specifically for the.NET platform. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

46  C# has roots in C, C++ and Java.  Like Visual Basic, C# is object oriented and has access to a powerful class library of prebuilt components, enabling you to develop applications quickly  Visual Basic and C# share the.NET Framework Class Library.  Both languages have similar capabilities to Java and are appropriate for the most demanding application development tasks, especially for building today’s enterprise applications, and web-based and mobile applications. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

47  In the late 1960s, ARPA—the Advanced Research Projects Agency of the Department of Defense—rolled out plans to network the main computer systems of some universities and research institutions.  ARPA implemented what quickly became known as the ARPAnet, the grandparent of today’s Internet.  Its main benefit proved to be the capability for quick and easy communication via e-mail.  This is true even on today’s Internet, with e-mail, instant messaging and file transfer allowing billions of people worldwide to communicate with each other. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

48  Businesses rapidly realized that by using the Internet, they could improve their operations and offer new and better services to their clients.  This generated fierce competition among communications carriers and hardware and software suppliers to meet the increased infrastructure demand.  As a result, bandwidth—the information-carrying capacity of communications lines—on the Internet has increased tremendously, while hardware costs have plummeted. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

49  The World Wide Web is a collection of hardware and software associated with the Internet that allows computer users to locate and view multimedia-based documents (documents with various combinations of text, graphics, animations, audios and videos) on almost any subject. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

50  In 1989, Tim Berners-Lee of CERN (the European Organization for Nuclear Research) began to develop a technology for sharing information over the Internet via “hyperlinked” text documents.  Berners-Lee called his invention the HyperText Markup Language (HTML).  He also wrote communication protocols such as HyperText Transfer Protocol (HTTP) to form the backbone of his new hypertext information system, which he referred to as the World Wide Web. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

51  In 1994, Berners-Lee founded the World Wide Web Consortium to develop technologies for the web.  One of the W3C’s goals is to make the web accessible to everyone regardless of disabilities, language or culture.  In the past, most computer applications ran on computers that were not connected to one another.  Today’s applications can be written to communicate among the world’s computers via the Internet and the web.  This is the focus of Microsoft’s.NET strategy.  We’ll discuss how to build web applications with Visual Basic. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

52  The Advanced Painter application allows you to draw on the screen with different brush sizes and colors.  The elements and functionality you see in this application are typical of what you’ll learn to program in this text. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

53  The following steps show you how to test-drive the application. ◦ Checking your setup. Confirm that you’ve set up your computer properly by reading the Before You Begin section located after the Preface. ◦ Locating the application directory. Open a Windows Explorer window and navigate to the C:\Examples\ch01 directory (Fig. 1.1)—we assume you placed the examples in the C:\Examples folder. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

54

55  Running the Advanced Painter application. Now that you’re in the proper directory, double click the file name AdvancedPainter.exe (Fig. 1.1) to run the application (Fig. 1.2). ◦ [Note: Depending on your system configuration, Windows Explorer might not display file name extensions. To display file name extensions (like.exe in Fig. 1.1), type Alt + T in Windows Explorer to open the Tools menu, then select Folder options…. In the Folder Options window, select the View tab, uncheck Hide extensions for known file types and click OK.]  Figure 1.2 labels several graphical elements—called controls. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

56

57  These include GroupBox es, RadioButton s, a Panel and Button s (these controls and many others are discussed in depth throughout the text).  The application allows you to draw with a red, blue, green or black brush of small, medium or large size.  You can also undo your previous operation or clear the drawing to start from scratch.  By using existing controls—which are objects—you can create applications faster than if you had to write all the code.  The brush’s properties, selected in the RadioButton s labeled Black and Medium, are default settings—the initial settings you see when you first run the application. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

58  Now you’ll choose your own settings as a user of this application. ◦ Changing the brush color and size. Click the RadioButton s labeled Red to change the color of the brush and Small to change the size of the brush. Position the mouse over the white Panel, then press and hold down the left mouse button to draw with the brush. Draw flower petals, as shown in Fig. 1.3. Then click the RadioButton labeled Green to change the color of the brush again. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

59

60 ◦ Changing the brush size. Click the RadioButton labeled Large to change the size of the brush. Draw grass and a flower stem, as shown in Fig. 1.4. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

61

62 ◦ Finishing the drawing. Click the Blue and Medium RadioButton s. Draw raindrops, as shown in Fig. 1.5, to complete the drawing. ◦ Closing the application. Close your running application by clicking its close box, (Fig. 1.5). © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

63

64  Object-oriented programming dramatically improved the software development process.  Object technology is a packaging scheme for creating meaningful software units.  There are date objects, time objects, paycheck objects, invoice objects, automobile objects, people objects, audio objects, video objects, file objects, record objects and so on.  On your computer screen, there are button objects, textbox objects, menu objects and many more.  Almost any noun can be represented as a software object.  Objects have attributes (also called properties), such as color, size and speed; and perform actions (also called methods or behaviors), such as moving, sleeping or drawing. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.

65  Classes are types of related objects.  For example, all cars belong to the “car” class, even though individual cars vary in make, model, color and options.  A class specifies the general format of its objects, and the attributes and actions of an object depend on its class.  An object is related to its class in much the same way as a building is related to its blueprint.  Contractors can build many buildings from the same blueprint. Programmers can instantiate many objects from one class.  With object technology, properly designed classes can be reused on future projects. © 1992-2010 by Pearson Education, Inc. All Rights Reserved.


Download ppt "Visual Basic 2010 How to Program © 1992-2010 by Pearson Education, Inc. All Rights Reserved."

Similar presentations


Ads by Google