1 / 49

Microsoft Visual Basic 2010: Reloaded Fourth Edition

Microsoft Visual Basic 2010: Reloaded Fourth Edition. Chapter One An Introduction to Visual Basic 2010. Overview. What Is a Computer? Machine, Assembly and High-Level Languages Visual Basic & Other High-Level Languages Object Technology The Internet and the World Wide Web

jean
Télécharger la présentation

Microsoft Visual Basic 2010: Reloaded Fourth Edition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft Visual Basic 2010: ReloadedFourth Edition Chapter One An Introduction to Visual Basic 2010

  2. Overview • What Is a Computer? • Machine, Assembly and High-Level Languages • Visual Basic & Other High-Level Languages • Object Technology • The Internet and the World Wide Web • Introduction to Microsoft .NET • Language and Syntax • Visual Studio 2010 IDE • Solutions and Projects • Creating a New Project • Examples

  3. What Is a Computer? • A computeris a device that can perform calculations and make logical decisions much faster than humans can. • Computers process data,using sets of instructions called computer programs. • These programs guide computers through orderly sets of actions that are specified by people known as computer programmers.

  4. What Is a Computer? • A computer is composed of various devicesknown as hardware: • keyboard • screen • mouse • hard drives • memory • DVD drives • printer • processing units • The programs that run on a computer are referred to as software.

  5. Computer Components Computers can be thought of as being dividedinto six units: • Input unit: This “receiving” section of the computer obtains information from input devices. • Input can come from devices such as the keyboard and the mouse. • Output unit: This “shipping” section of the computer takes information that the computer has processed and places it on various output devices. • Output can be displayed on screens, printed on paper, played on audio/video devices, and transmitted over the Internet.

  6. Computer Components • Memory unit: This “warehouse” section of the computer stores data while an application is running. Its information is immediately available for processing. • To be executed, computer programs must be in memory. • The memory unit retains information until it can be sent to output devices. • Often, the memory unit is called either memoryorprimary memory. • Random-access memory (RAM) is an example of primary memory. • Primary memory is usually volatile, which means that it is erased when the machine is powered off.

  7. Computer Components • Central processing unit (CPU): The CPU supervises the operation of the other sections. • Arithmetic and logic unit (ALU): The ALU (a part of the CPU) performs calculations and makes decisions. • Secondary storage unit: This unit is the “warehousing” section of the computer. • Devices such as hard drives, CD-ROM drives, DVD drives, and USB memory sticks are secondary storage units. • These normally hold programs or data that other units are not actively being used. • The computer can retrieve this information when it is needed later in time. Secondary storage is nonvolatile. • Information in secondary storage takes much longer to access than information in primary memory.

  8. Machine, Assembly and High-Level Languages • Programmers write instructions in programming languages. Some of these are directlyunderstandable by computers, and others require intermediate translation steps. • Computer languages that are in use today can be divided into three general types: • machine languages • assembly languages • high-level languages

  9. Machine, Assembly and High-Level Languages • A computer can directly understand only its own machine language. • As the “natural language” of a particular computer, machine language is defined by the computer’s hardware design. Machine languages are machine dependent. • Machine languages generally consist of streams of numbers (ultimately reduced to 1s and 0s in the binary number system).

  10. Machine, Assembly and High-Level Languages • The following section of a machine-language program demonstrates the incomprehensibility of machine language to humans: +1300042774+1400593419+1200274027 • Machine-language programming proved to be slow and error prone.

  11. Machine, Assembly and High-Level Languages • Programmers began using English-like abbreviations to represent the computer’s basic operations. • These abbreviations formed the basis of assembly languages.LOAD BASEPAYADD OVERPAYSTORE GROSSPAY

  12. Machine, Assembly and High-Level Languages • Translator programs called assemblers convert assembly-language programs to machine language. • Although it is clearer to humans, computers cannot understand assembly-language code until it is translated into machine language. • Assembly languages still require many instructions to accomplish even the simplest tasks.

  13. Machine, Assembly and High-Level Languages • To speed up the programming process,high-level languages were developed. • Programs called compilers convert high-level-language programs into machine language. • High-level languages look almost like everyday English and contain common mathematical notations. grossPay = basePay + overTimePay • Visual Basic is one of the world’s most popularhigh-level programming languages.

  14. Visual Basic • Visual Basic evolved from BASIC (Beginner’s All-purpose Symbolic Instruction Code), which was developed as a language for writing simple programs quickly and easily. • When Bill Gates founded Microsoft Corporation in the 1970s, he implemented BASIC on several early personal computers.

  15. Visual Basic • In the late 1980s and the early 1990s, Microsoft developed the Microsoft® Windows®graphical user interface (GUI). • Visual Basic was introduced by Microsoft in 1991 to make programming Windows applications easier.

  16. Visual Basic • Visual Basic is a so-called object-oriented,event-driven visual programming language. • Programs are created with the use of a softwaretool called an Integrated Development Environment (IDE). • The latest versions of Visual Basic are fully object oriented and respond to user-initiated events such as mouse clicks, keystrokes and timers. • In Visual Studio, it is convenient to make programs by dragging and dropping predefined objects like buttons and textboxes.

  17. Visual Basic • Microsoft introduced its .NET strategy in 2000. • The .NETplatform allows applications to be distributed to a variety of devices. • Software components created in different .NET programming languages can communicate with one another.

  18. Other High-Level Languages • Although hundreds of high-level languages have been developed, only a few have achieved broad acceptance. • IBM Corporation developed Fortran in themid-1950s to create scientific and engineering applications. • COBOL was developed in the late 1950s by a group of computer manufacturers. COBOL is used primarily for business applications that require the manipulation of large amounts of data.

  19. Other High-Level Languages • The C language gained widespread recognition asa development language for the UNIX operating system. • C++ was developed by Bjarne Stroustrup in the early 1980s at Bell Laboratories. C++ provides capabilities for object-oriented programming (OOP). • Objects are reusable software components that model items in the real world. • Object-oriented programs are easier to understand, correct and modify.

  20. Other High-Level Languages • Developers use Java to create web pages with dynamic content, to build large-scale enterprise applications, to enhance the functionality of web servers, and to provide applications for consumer devices. • In 2000, Microsoft announced C#. The C# programming language was designed specifically for the .NET platform. Like Visual Basic, C# is object oriented and has access to .NET’s library.

  21. Object Technology • Object technology is a packaging scheme for creating meaningful software units. • Almost any noun can be reasonably represented as a software object. • Objects: • have properties such as color, size and weight • perform actions such as moving, sleeping or drawing • A class specifies the general format of its objects, and the properties and actions available to an object depend on its class.

  22. Object Technology • Procedural programming languages focused on actions (verbs) rather than objects (nouns). • Object-oriented languages more naturally reflects the way in which we perceive the world. • This has resulted in significant productivity gains. • Properly designed classes can be reused on future projects • Using libraries of classes reduces the amount of effort required to implement new systems • The production of software is more understandable because it is better organized and has fewer maintenance requirements.

  23. Object Technology • Instead of worrying about the details of how objects are implemented, you can focus on the behaviors and interactions of objects. • Visual Basic is one of the world’s most widely used object-oriented languages.

  24. The Internet and the World Wide Web • In the late 1960s, ARPA rolled out plans to network the main computer systems of ARPA-funded universities and research institutions. • This 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 what came to be known as electronic mail (e-mail).

  25. The Internet and the World Wide Web • The protocol for communicating over the ARPAnet became known as the Transmission Control Protocol (TCP). • TCP ensured that messages, consisting of pieces called “packets,” were properly routed from sender to receiver, arrived intact and were assembled in the correct order. • One challenge was to enable different networks to communicate with each other. • ARPA accomplished this by developing theInternet Protocol (IP), which created the current architecture of the Internet. • The combined set of protocols is now called TCP/IP.

  26. The Internet and the World Wide Web • The World Wide Web is a collection of hardware and software associated with the Internet. • In 1989, Tim Berners-Lee of CERN began to develop a technology for sharing information via “hyperlinked” text documents called HyperText Markup Language (HTML). • He also wrote communication protocols such as HyperText Transfer Protocol (HTTP). • In October 1994, Berners-Lee founded the World Wide Web Consortium, devoted to developing technologies for the World Wide Web.

  27. The Internet and the World Wide Web • The Internet and the web will surely be listed among the most important creations of humankind. • Today’s applications can be written to communicate among the world’s computers. This is the focus of Microsoft’s .NET strategy. • The Internet and the World Wide Web: • make information instantly and conveniently accessible, • and allow individuals and small businesses to achieve worldwide exposure.

  28. Introduction to Microsoft .NET • In June 2000, Microsoft announced its.NET initiative • The .NET initiative permits developers to create applications in any .NET-compatible language. • Part of the initiative includes Microsoft’s ASP.NET. • The .NET strategy extends the idea of software reuse to the Internet. • Visual programming enables .NET programmers to create applications using prepackaged graphical components.

  29. .NET Framework • The Microsoft .NET Framework: • executes applications and web services • contains a class library (Framework Class Library) • and provides many other programming capabilities. • The .NET framework is a platform with which you can develop software applications and libraries called managed applications; it provides you with the compiler and tools you need to build, debug, and execute managed applications. • Prior to this approach, unmanaged applications had to manage their own services which sometimes led to erroneous code, security holes and data corruption.

  30. .NET Framework • CLR: Common Language • WCF: Windows Communication Foundation • WPF: Windows Presentation Foundation • WF: Windows Workflow Foundation • LINQ: Language Integrated Query • Cardspace: Manages online identities • AJAX: Asynchronous JavaScript and XML • REST: Representational State Transfer

  31. .NET Framework

  32. Spoken Languages and Syntax • Sprechen Sie Englisch? • ¿Habla ingles? • Você fala inglês? • OO-day ou-yay eak-Spay Eng-hay ish-lay?

  33. Examples of Programming Languages • C: fast, efficient code • Java: platform independence • BASIC: ease of use • Visual Basic: user interface design using forms • Perl: text manipulation

  34. Visual Basic.NET syntax If x>5 Then MessageBox.Show("I am greater than 5.") Else MessageBox.Show ("I am not greater than 5.") End If

  35. C# Syntax if (x>5) { MessageBox.Show ("I am greater than 5."); } else { MessageBox.Show ("I am not greater than 5."); }

  36. Learning a Programming Language • Syntax • Structure • Rules • Punctuation • Reserved Words (keywords) eg. If, Else • Visual Basic.NET is NOT case sensitive. MyCase is the same as myCase and MYCASE. • Comment lines start with an apostrophe (')

  37. Visual Studio 2010 IDE • Visual Studio® 2010 is Microsoft’s integrated development environment (IDE) for creating, running and debugging applications. • The IDE allows you to create applications by dragging and dropping existing building blocks into place. • This technique is called visual programming. • It is a Rapid Application Development (RAD) tool because it is focused on productivity.

  38. Visual Studio 2010 Languages • Visual Basic.NET • C# (pronounced C-Sharp) • J# (pronounced J-Sharp) • C++ (pronounced C plus plus) • ASP.NET (web page creation)

  39. Visual Basic 2010 Express • Visual Basic Express is a compact development environment for creating Visual Basic.NET applications. • Can create different types of applications • Windows Applications (Windows Forms or WPF Application) • Console Applications • Reusable components or class libraries • Cannot build web sites or web services with the Visual Basic Express Edition.

  40. Some Advantages of Visual Basic 2010 Express IDE • Greatly reduces amount of code you must write • Automatically colors code depending what it is • Comments are Green • Keywords are Blue • Organizes code in separate files • IntelliSense • Code Snippets • Real-time compiler feedback • Blue squiggle under code indicates an error • Green squiggle under code indicates a possible error

  41. Solutions and Projects • Visual Basic organizes applications into solutions and projects. • Solutions contain one or more projects. • A project is a group of related files, such as codeand images that might make up a program.

  42. Solutions, Projects, and Files

  43. Creating a New Project • Select either File > New Project…, which creates a new project, or File > Open Project…, which opens an existing project. • From the Start Page, under the Recent Projects section, click the link Create: Project… or Open: Project…. • Click either the New ProjectButton or the Open FileButton.

  44. Working With a Project • The Solution Explorer window displays a list of the files in a project and the projects in a solution. • The Properties window displays an object’s attributes, such as its size, color and position. The Properties window allows you to set object properties visually without writing code. • Using visual programming, you can “drag and drop” controls onto the Form from the Toolbox. Properties icon Object Browser icon Solution Explorer icon Toolbox icon

  45. Properties Window Object’sname(Form1) Object’s class (System.Windows.Forms.Form) Down arrow for selecting Formor control objects Component object box Categorized icon Alphabetical icon Items that have beenchanged from their defaultvalues (by the user or by VisualStudio) are listed in bold Selected property Design category Description ofselected property Properties(left column) Property values(right column) Figure 2.22|Properties window displaying a Form’s properties.

  46. Form Controls

  47. Hello World! Console App:         Console.WriteLine("Hello World") Windows Form App:         MessageBox.Show("Hello World!")

  48. Web Browser • Create form • Text: My Own Browser • Width/Height: (640,480) • Create Webrowser control • Width/Height: (607,385) • X/Y: (12,12) • Name: myBrowser • Create textbox • Width/Height: (526,20) • X/Y: (12,411) • Name: txtURL

  49. Web Browser (cont.) • Create button • Text: GO • X/Y: (544,411) • Name: btnGo • Add this line of code to the button: myBrowser.Navigate(txtURL.Text)

More Related