Exploring the Visual Studio Integrated Development Environment.

58
Exploring the Visual Studio Integrated Development Environment

Transcript of Exploring the Visual Studio Integrated Development Environment.

Page 1: Exploring the Visual Studio Integrated Development Environment.

Exploring the Visual Studio Integrated Development Environment

Page 2: Exploring the Visual Studio Integrated Development Environment.

ObjectivesUnderstand software and computer programsDefine Microsoft Visual Basic and identify the

common features of Windows applications.Identify and use the basic tools in the Visual

Studio .NET integrated development environment.

Design a form and add objects to it.Explain the meaning of "event-driven" and write

code for an event procedure.Understand and use the Help system.

2

Page 3: Exploring the Visual Studio Integrated Development Environment.

VocabularyBuildsClassCodeControlsDialog boxEvent-drivenEvent procedureEventsFile extensionForm

Graphical user interface (GUI)

Instantiation Integrated development

environment (IDE)MenusMethodObjectsPropertiesSolutionToolTip

3

Page 4: Exploring the Visual Studio Integrated Development Environment.

Historically SpeakingThe first general‑purpose computer of the modern age was the ENIAC—The Electronic Numerical Integrator and Computer. It was invented to do only one thing, calculate firing tables for missiles in the Second World War. The ENIAC consisted of more than 18,000 vacuum tubes and filled a large room. To program the ENIAC, it had to be completely rewired. It was a far cry from what we have today. Its inventors, J. Eckert and John Mauchley, went on to found the first American computer company called UNIVAC.

4

Page 5: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 5

Introduction

►The set of instructions that directs a computer to perform tasks is called computer software, or a computer program

Page 6: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 6

Introduction

►Computer hardware is the physical equipment associated with a computer

Page 7: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 7

Introduction

►The basic function of many computer programs is to accept data, manipulate the data (process), and create output data or information

Page 8: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 8

Introduction

►In order for the computer to execute a program:• Program and data must be placed in the

computer’s random access memory (RAM)• The central processing unit (CPU) can

access the instructions in the program and the data in RAM to perform activities directed by the program

Page 9: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 9

Introduction

►Saving, or storing, data refers to placing the data or software electronically on a storage medium• Hard disk• Universal Serial Bus (USB) drive

►Persistent data remains available even after the computer power is turned off

Page 10: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 10

Computer Programmers and Developers

►A computer program is designed and developed by people known as computer programmers, or developers

►Developers are people skilled in designing computer programs and creating them using programming languages

►Applications may consist of several computer programs working together to solve a problem

►Computer programmers write the code for programs using a programming language

Page 11: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 11

Computer Programmers and Developers

Page 12: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 12

Event-Driven Computer Programs with a Graphical User Interface

►Most Visual Basic 2005 programs are event-driven programs that communicate with the user through a graphical user interface (GUI)• A GUI usually consists of a window, containing

a variety of objects►An event means the user has initiated an action

that causes the program to perform the type of processing called for by the user’s action

Page 13: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 13

Event-Driven Computer Programs with a Graphical User Interface

►For example:• The user enters the account number in the

Account Number box• The user clicks the Display Account Balance

button• The user clicks the Reset Window button to

clear the text boxes and prepare the user interface for the next account number

Page 14: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 14

Input Operation

Page 15: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 15

Output Operation

Page 16: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 16

Visual Basic 2005 and Visual Studio 2005

Page 17: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 17

Programming Languages

►Visual Basic 2005• Based on the Visual Basic programming language that

Microsoft developed in the early 1990s• Based on the BASIC language

►C++• Derivative of the programming language, C

►Visual C#• Synthesis of C++ syntax and Visual Basic productivity

benefits►Visual J#• Java language for use with Visual Studio

Page 18: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 18

.NET Framework 2.0

►.NET technologies and products were designed to work together to allow businesses to connect information, people, systems, and devices through software

►The .NET Framework provides tools and processes developers can use to produce and run programs• Most recent version is .NET Framework

2.0

Page 19: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 19

.NET Class Library

►A class is a named group of program code• A button is an example of a class

►A class library stores the class and makes the class available to all developers who need to use it

Page 20: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 20

.NET Class Library

►A button created from a class is called an object, or sometimes an instance of a class

►The process of creating a Button object from the Button class is called instantiation

►Rapid application development (RAD) refers to the process of using prebuilt classes to make application development faster, easier, and more reliable

Page 21: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 21

ADO.NET 2.0

►ADO.NET 2.0 (ActiveX Data Objects) provides the functionality for a program to perform four primary tasks when working with a database:• Get the data• Examine the data• Edit the data• Update the data

Page 22: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 22

ASP.NET 2.0

►Allows developers to use Visual Studio 2005 to build Web application

►Almost all .NET framework objects are available in ASP.NET 2.0

►Easy to deploy a Web application on a Web server

Page 23: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 23

Microsoft Intermediate Language (MSIL) and Common Language Runtime (CLR)

►Program compilation translates programming statements into instructions that can be understood by the electronics of the computer

►Program compilation for a Visual Basic 2005 program creates a set of electronic code expressed in an intermediate language called the Microsoft Intermediate Language (MSIL)

►When the program is executed, a portion of .NET 2.0 called the Common Language Runtime (CLR) reads the MSIL and causes the actual instructions within the program to be executed

Page 24: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 24

Microsoft Intermediate Language (MSIL) and Common Language Runtime (CLR)

Page 25: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 25

Types of Visual Basic 2005 Applications

►Windows application• Program will run on a computer or other device

that supports the Windows GUI►Mobile application• Designed to run on mobile devices running the

Windows CE operating system►Web site application• Uses ASP.NET 2.0 and runs on a Web server

Page 26: Exploring the Visual Studio Integrated Development Environment.

1

Chapter 1: Introduction to Visual Basic 2005 Programming 26

Types of Visual Basic 2005 Applications

►Office application• Includes Writing Visual Basic 2005 code to

automate and manipulate documents created using Microsoft Office

►Database application• Written using ADO.NET 2.0 to reference,

access, display, and update data stored in a database

►Other types of applications include console applications, classes for class libraries, Web services, and device-specific applications

Page 27: Exploring the Visual Studio Integrated Development Environment.

Common Windows Objects

27

Title bar

Menu bar

Toolbar

Menu

Minimizebutton

Maximize/Restore

Page 28: Exploring the Visual Studio Integrated Development Environment.

Shortcut Keys for File Menu Commands

28

Shortcut keys

Page 29: Exploring the Visual Studio Integrated Development Environment.

Visual Studio Integrated Development Environment (IDE)

29

Page 30: Exploring the Visual Studio Integrated Development Environment.

New Project Dialog Box

30

Page 31: Exploring the Visual Studio Integrated Development Environment.

An Empty Visual Basic Project in the Visual Studio IDE

31

Page 32: Exploring the Visual Studio Integrated Development Environment.

NoteEach application program is called a project. Some applications require more than one project. The collection of projects that form an application is called a solution. The Solution Explorer shows the files and components that make up the solution.

32

Page 33: Exploring the Visual Studio Integrated Development Environment.

The Visual Basic Standard Toolbar

33

Page 34: Exploring the Visual Studio Integrated Development Environment.

NoteThe Tools menu and the Toolbox window may vary from system to system due to different system configurations.

34

Page 35: Exploring the Visual Studio Integrated Development Environment.

The Standard Toolbar Showing the Add New Item ToolTip

35

Page 36: Exploring the Visual Studio Integrated Development Environment.

NoteToolTips give a short explanation of what a control does. They appear as yellow boxes near a control when your mouse pointer rests over the control

36

Page 37: Exploring the Visual Studio Integrated Development Environment.

The Add New Item Box

37

Page 38: Exploring the Visual Studio Integrated Development Environment.

NoteMenu commands and buttons appear in color or solid black when they can be used and are grayed out when they cannot be used.

38

Page 39: Exploring the Visual Studio Integrated Development Environment.

The Visual Basic Toolbox

39

Page 40: Exploring the Visual Studio Integrated Development Environment.

Building Communication SkillsBefore starting any project, it is important to make sure that you, the programmer, understand exactly what your client expects from the program. One of the best ways of making this happen is to interview the client or the client's users. Do not assume that, just because you think something should be done one way, the client thinks the same thing.

40

Page 41: Exploring the Visual Studio Integrated Development Environment.

NoteAttaching your program tools to a particular place in the development environment is called docking.

41

Page 42: Exploring the Visual Studio Integrated Development Environment.

NoteDouble‑click a tool in the Toolbox and a control of default size appears on the form.

42

Page 43: Exploring the Visual Studio Integrated Development Environment.

Understanding the Solution Explorer WindowThe Solution Explorer window lists all of the forms and modules used in the project or projects that make up the complete application called the solution.

43

Page 44: Exploring the Visual Studio Integrated Development Environment.

The Solution Explorer Window

44

Page 45: Exploring the Visual Studio Integrated Development Environment.

Examining the Properties Window Like any physical object, each object in Visual Basic has properties. The properties describe the object's appearance, position, and behavior. The Properties window lists the characteristics for the selected form or object. The left column displays the names of the properties associated with the selected object and the right column displays the current setting for that property.

45

Page 46: Exploring the Visual Studio Integrated Development Environment.

Properties Window

46

Page 47: Exploring the Visual Studio Integrated Development Environment.

Building Programming SkillsDespite legal battles that have embroiled Microsoft over the last few years, the company has brought a level of continuity to the PC environment. Windows users, as a result, have come to expect certain things when they launch a Windows application. It would be unwise for a programmer who wanted to sell an application to deviate from industry standards.

47

Page 48: Exploring the Visual Studio Integrated Development Environment.

TipAn easy way to change a property setting is to double‑click the property's name (not the name of the object) in the left column. The property setting is selected and ready to be replaced. Once selected, just keying a new value from the keyboard will replace the old value. Double-clicking a property's name in the left column of the Properties window may change the property's value by cycling through the possible values.

48

Page 49: Exploring the Visual Studio Integrated Development Environment.

TipThe properties are listed in alphabetical order with the exception of Name, which is at the top. While each object has its own unique set of properties, every object has a Name property. Visual Basic automatically gives each object a name when it is created, but the values are not particularly descriptive (for example, Form1). It is a good idea to give each object a more descriptive name after adding it to the project because you use the object's Name property when writing code.

49

Page 50: Exploring the Visual Studio Integrated Development Environment.

Computer EthicsAs a programmer, it is important to remember to give credit where credit is due. If you use someone else's work, make sure you have permission to use their work and give them credit for it.

50

Page 51: Exploring the Visual Studio Integrated Development Environment.

The Visual Basic ProjectA Visual Basic project is composed of all the forms, controls, code, and other items that make up the entire application. You may also want to add prebuilt components to your application. By using all of the tools available to you, powerful applications can be created quickly and efficiently.

51

Page 52: Exploring the Visual Studio Integrated Development Environment.

Creating a FormThe form may have buttons, scroll bars, menus, list boxes, menus, and any of the other features that are common to Windows programs. Forms are the main building blocks of an application. You begin by creating the forms, adding the controls, writing the code, testing the application, and then finally using it in its actual setting. Proper planning helps ensure that users will be able to quickly find their way around a program. It is the programmer's responsibility to consider the multitude of users that may access their program and anticipate all of the different options that they may need.

52

Page 53: Exploring the Visual Studio Integrated Development Environment.

NoteIn Microsoft Word, you may close a document before closing Word, although it is unnecessary to do so. You might be tempted to right-click the project name in the Solution Explorer and select Remove to remove the current project from Visual Basic; do not do so. Later in the book, you will have two projects open at the same time. This creates a solution with multiple projects. The Remove Project command is meant to remove a second (or third) project from a solution. It is not meant to remove a project at the end of a programming session.

53

Page 54: Exploring the Visual Studio Integrated Development Environment.

Class Name List Box

54

Page 55: Exploring the Visual Studio Integrated Development Environment.

NoteIf you click the Class Name list box, you will see four entries: Form1 (MyFirst), (Overrides), IblHello, and Form1. Form1 and IblHello correspond to the objects that are available to this application at this point. If you were to add additional controls, they would be listed here as well.

55

Page 56: Exploring the Visual Studio Integrated Development Environment.

SummaryMicrosoft Visual Basic .NET is a set of programming tools

that allows you to create applications for the Windows operating system and for the Internet.

Programs in Visual Basic are event‑driven. Users initiate an event with a mouse click or by pressing a key.

The code written by a programmer to respond to an event is called a method.

The Solution Explorer lists all the files and modules that make up an application. It may contain information about more than one project.

The toolbar provides easy access to frequently performed commands. A number of specialized toolbars can be displayed to make other commands readily available.

56

Page 57: Exploring the Visual Studio Integrated Development Environment.

SummaryThe Toolbox contains many controls that you can add to

your forms. More controls can be added to the Toolbox to give you even greater capabilities.

The Properties window lists the properties information for a selected form or object.

Standard prefixes have been developed for commonly used controls.

It is important to give all objects descriptive names. Build the names with the appropriate prefix followed by one or more words starting with uppercase letters. The word(s) should describe the control’s use.

57

Page 58: Exploring the Visual Studio Integrated Development Environment.

SummaryA Visual Basic project is composed of all the forms,

controls, code, and other items that make up an application. Use the Solution Explorer to view those components.

Files are designated by the filename, a period, and the file extension.

Programs in Windows work based on messages that generate events for the application. Each event executes code contained in the event’s method.

Select items in the Debug menu to run the program.To exit Visual Basic, choose Exit from the File menu or

click the Close button on the title bar.

58