meljun cortes

53
I. INTRODUCTION Visual Basic 2005 Visual Basic 2005 MELJUN CORTES MELJUN CORTES

Upload: meljun2525

Post on 08-May-2020

7 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: MELJUN CORTES

I. INTRODUCTIONVisual Basic 2005Visual Basic 2005

MELJUN CORTESMELJUN CORTES

Page 2: MELJUN CORTES

Introduction to .NET, Visual Basic and Introduction to .NET, Visual Basic and Object TechnologyObject TechnologyObjectives

INTRODUCTION 2

In this chapter you will learn:• The history of the Visual Basic programming language.• Some basics of object technology.• The brief history of the Internet and the World Wide Web.• The motivation behind and an overview of Microsoft's .NET

initiative• To test-drive a Visual Basic 2005 application.

Visual Basic 2005

Page 3: MELJUN CORTES

Visual BasicVisual Basic

Visual Basic evolved from BASIC (Beginner's All-Purpose Symbolic Instruction Code)

Developed in the mid-1960s by Professors John Kemeny and Thomas Kurtz of Dartmouth College as a language for writing simple programs

BASIC's primary purpose was to familiarize novices with programming techniques

INTRODUCTION 3

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 4: MELJUN CORTES

Visual BasicVisual Basic

The natural evolution of BASIC was Visual Basic, introduced by Microsoft in 1991

Visual Basic makes the development of Windows applications convenient

Microsoft announced the introduction of its .NET (pronounced "dot-net") strategy in 2000

4INTRODUCTION

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 5: MELJUN CORTES

Visual BasicVisual Basic

The .NET platform is one over which Web-based applications can be distributed to a variety of devices and to desktop computers

The .NET platform enables programs created in different programming languages to communicate easily with each other

Visual Basic offers powerful object-oriented programming capabilities

INTRODUCTION 5

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 6: MELJUN CORTES

The Internet and World Wide WebThe Internet and World Wide Web

The Internet was originally designed to connect the main computer systems of about a dozen universities and research organizations

The Internet has exploded into one of the world's premier communication mechanisms and continues to grow rapidly

INTRODUCTION 6

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 7: MELJUN CORTES

The Internet and World Wide WebThe Internet and World Wide Web

The World Wide Web allows computer users to locate and view multimedia-based documents on almost any subject over the Internet

In 1989, Tim Berners-Lee of CERN (the European Organization for Nuclear Research) began to develop a technology for sharing information via hyperlinked text documents

INTRODUCTION 7

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 8: MELJUN CORTES

The Internet and World Wide WebThe Internet and World Wide Web

In 1994, Tim Berners-Lee founded an organization, called the World Wide Web Consortium(W3C)

The W3C (www.w3.org) is also a standardization organization

Web technologies standardized by the W3C are called Recommendations

Current W3C Recommendations include the Extensible Markup Language(XML)

INTRODUCTION 8

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 9: MELJUN CORTES

Microsoft’s .NETMicrosoft’s .NET

In 2000, Microsoft announced its .NET initiative

A new vision for embracing the Internet and the Web in the development and use of software

One key aspect of .NET is its independence from a specific language or platform

INTRODUCTION 9

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 10: MELJUN CORTES

Microsoft’s .NETMicrosoft’s .NET

The .NET architecture can exist on multiple platforms, not just Microsoft Windows based systems

A key component of the .NET architecture is Web services

The .NET strategy extends the concept of software reuse to the Internet

INTRODUCTION 10

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 11: MELJUN CORTES

The .NET Framework and the Common The .NET Framework and the Common Language RuntimeLanguage Runtime

The Microsoft .NET Framework is at the heart of the .NET strategy

This framework manages and executes applications and Web services, contains a class library (called the .NET Framework. Class Library, or FCL), enforces security and provides many other programming capabilities

INTRODUCTION 11

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 12: MELJUN CORTES

The .NET Framework and the Common The .NET Framework and the Common Language RuntimeLanguage Runtime

The details of the .NET Framework are found in the Common Language Infrastructure (CLI)

INTRODUCTION 12

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 13: MELJUN CORTES

The .NET Framework and the Common The .NET Framework and the Common Language RuntimeLanguage Runtime

The Common Language Runtime (CLR) is another central part of the .NET Framework - it executes .NET programs

Programs are compiled into machine-specific instructions in two steps:◦First, the program is compiled into Microsoft

Intermediate Language (MSIL), which defines instructions for the CLR

◦Second, the MSIL for an application's components is placed into the application's executable file

INTRODUCTION 13

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 14: MELJUN CORTES

The .NET Framework and the Common The .NET Framework and the Common Language RuntimeLanguage Runtime

The ability of a program to run (without modification) across multiple platforms is known as platform independence

The .NET Framework also provides a high level of language interoperability

The .NET Framework Class Library FCL contains a variety of reusable components, saving programmers the trouble of creating new components

INTRODUCTION 14

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 15: MELJUN CORTES

Test-Driving a Visual Basic ApplicationTest-Driving a Visual Basic ApplicationINTRODUCTION 15

Introduction to .NET, Visual Basic and Object Technology

Visual Basic 2005

Page 16: MELJUN CORTES

Introduction to the Visual Basic 2005 Introduction to the Visual Basic 2005 IDEIDEObjectives

INTRODUCTION 16

In this chapter you will learn:•The basics of the Visual Studio Integrated Development Environment (IDE) that assists you in writing, running and debugging your Visual Basic programs.•Visual Studio's help features.•Key commands contained in the IDE's menus and toolbars.•The purpose of the various kinds of windows in the Visual Studio 2005 IDE.•What visual programming is and how it simplifies and speeds program development.•To create, compile and execute a simple Visual Basic program that displays text and an image using the Visual Studio IDE and the technique of visual programming.

Visual Basic 2005

Page 17: MELJUN CORTES

Overview of the Visual Studio 2005 IDEOverview of the Visual Studio 2005 IDE

There are many versions of Visual Studio available◦Visual Studio 97◦Visual Studio 6.0◦Visual Studio .NET 2002◦Visual Studio .NET 2003◦Visual Studio 2005◦Visual Studio 2008◦Visual Studio express editions

INTRODUCTION 17

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 18: MELJUN CORTES

Overview of the Visual Studio 2005 IDEOverview of the Visual Studio 2005 IDEINTRODUCTION 18

Start Page tab

New Project button

Toolbox

Start Page links

Empty Solution Explorer

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 19: MELJUN CORTES

Overview of the Visual Studio 2005 IDEOverview of the Visual Studio 2005 IDE

New Project dialog

INTRODUCTION 19

Introduction to the Visual Basic 2005 IDE

Visual Basic Windows Application

(selected)

Default project name Description of selected project

Visual Basic 2005

Page 20: MELJUN CORTES

Overview of the Visual Studio 2005 IDEOverview of the Visual Studio 2005 IDE

Design view of the IDE

INTRODUCTION 20

Introduction to the Visual Basic 2005 IDE

Active tab Tabs Menu Menu bar

Solutionexplorer

Properties window

Form design(Windows Application)

Visual Basic 2005

Page 21: MELJUN CORTES

Overview of the Visual Studio 2005 IDEOverview of the Visual Studio 2005 IDE

Dialog for modifying a control's font properties

INTRODUCTION 21

Introduction to the Visual Basic 2005 IDE

Font dialogwindow

Visual Basic 2005

Page 22: MELJUN CORTES

Menu Bar and ToolbarMenu Bar and Toolbar

Commands for managing the IDE and for developing, maintaining and executing programs are contained in menus

The set of menus displayed depends on what you are currently doing in the IDE

INTRODUCTION 22

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Menu bar

Page 23: MELJUN CORTES

Menu Bar and ToolbarMenu Bar and Toolbar

Menu Description

File Contains commands for opening, closing, adding and saving projects, as well as printing project data and exiting Visual Studio.

Edit Contains commands for editing programs, such as cut, copy, paste, undo, redo, delete, find and select.

View Contains commands for displaying windows (e.g., Solution Explorer, Toolbox, Properties window) and for adding toolbars to the IDE.

Project Contains commands for managing projects and their files.

Build Contains commands for compiling programs.

Debug Contains commands for debugging (i.e., identifying and correcting problems in programs) and running programs.

Data Contains commands for interacting with databases (i.e., organized collections of data stored on computers).

Format Contains commands for arranging and modifying a form's controls. Note that the Format menu appears only when a GUI component is selected in Design view.

Continued……

INTRODUCTION 23

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 24: MELJUN CORTES

Menu Bar and ToolbarMenu Bar and ToolbarINTRODUCTION 24

Introduction to the Visual Basic 2005 IDE

Menu Description

Tools Contains commands for accessing additional IDE tools (e.g., the Toolbox) and options that enable customization of the IDE.

Window Contains commands for arranging and displaying windows.

Community Contains commands for sending questions directly to Microsoft, checking question status, sending feedback on Visual Basic and searching the Code-Zone developer center and the Microsoft developers community site.

Help Contains commands for accessing the IDE's help features.

Visual Basic 2005

Page 25: MELJUN CORTES

Menu Bar and ToolbarMenu Bar and Toolbar

Standard Visual Studio toolbar

INTRODUCTION 25

Introduction to the Visual Basic 2005 IDE

Newproject

Openfile

Saveall

Add newitem

Save Cut

Copy

Paste

Undo

Redo

Navigatebackward

Navigateforward

Startdebugging

Solutionconfiguration

Solutionplatform

Find infiles

Find

Solution explorer

Properties window

Object browser

Toolbox

Command window

Start page

Visual Basic 2005

Page 26: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

The IDE provides windows for accessing project files and customizing controls

In this section, we introduce several windows that you will use frequently when developing Visual Basic programs

These windows can be accessed via the toolbar icons or by selecting the name of the desired window in the View menu

INTRODUCTION 26

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 27: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

Toolbar icons for Visual Studio windows

INTRODUCTION 27

Introduction to the Visual Basic 2005 IDE

SolutionExplorer

PropertiesWindow

ObjectBrowser

Toolbox

Visual Basic 2005

Page 28: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

Auto-hide feature

INTRODUCTION 28

Introduction to the Visual Basic 2005 IDE

Icon forHiddenWindow

Visual Basic 2005

Page 29: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

Auto-hide feature

INTRODUCTION 29

Introduction to the Visual Basic 2005 IDE

Window isshown when

the window iconis clicked

Visual Basic 2005

Page 30: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

The Solution Explorer◦The Solution Explorer window provides access

to all of the files in a solution

INTRODUCTION 30

Introduction to the Visual Basic 2005 IDE

Toolbar

Startup Project

Visual Basic 2005

Page 31: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

The Solution Explorer◦Solution Explorer showing plus boxes and

minus boxes for expanding and collapsing the tree to reveal or hide project files

INTRODUCTION 31

Introduction to the Visual Basic 2005 IDE

Plus box

Minus box

Visual Basic 2005

Page 32: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

The Toolbox◦The Toolbox contains icons representing

controls used to customize forms

INTRODUCTION 32

Introduction to the Visual Basic 2005 IDE

Group names

. . .

Controls

Visual Basic 2005

Page 33: MELJUN CORTES

Navigating the Visual Studio IDENavigating the Visual Studio IDE

The Properties Window◦The Properties window displays the properties

for the currently selected Form, control or file in design view

INTRODUCTION 33

Introduction to the Visual Basic 2005 IDE

Categorized icon

Alphabetic icon

Component selectiondrop-down list

Toolbar

Properties

Description

Propertyvalues

Visual Basic 2005

Page 34: MELJUN CORTES

Using HelpUsing Help

Visual Studio provides extensive help features

INTRODUCTION 34

Introduction to the Visual Basic 2005 IDE

Command Description

How Do I? Contains links to relevant topics, including how to upgrade programs and learn more about Web services, architecture and design, files and I/O, data, debugging and more.

Search Finds help articles based on search keywords.

Index Displays an alphabetized list of topics you can browse.

Contents Displays a categorized table of contents in which help articles are organized by topic.

Visual Basic 2005

Page 35: MELJUN CORTES

Using HelpUsing Help

Dynamic help is an excellent way to get information quickly about the IDE and its features

INTRODUCTION 35

Introduction to the Visual Basic 2005 IDE

Dynamic helpwindow

Visual Basic 2005

Page 36: MELJUN CORTES

Using HelpUsing HelpINTRODUCTION 36

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 37: MELJUN CORTES

Using Visual Programming to Create a Using Visual Programming to Create a Simple Program Simple Program

INTRODUCTION 37

Introduction to the Visual Basic 2005 IDE

Visual Basic 2005

Page 38: MELJUN CORTES

Introduction to Visual Basic Introduction to Visual Basic ProgrammingProgrammingObjectives

INTRODUCTION 38

In this chapter you will learn:•To write simple Visual Basic programs using code rather than visual programming.•To write statements that input data from the keyboard and output data to the screen.•To declare and use data of various types.•To store and retrieve data from memory.•To use arithmetic operators to perform calculations.•To use the precedence of arithmetic operators to determine the order in which operators are applied.•To write decision-making statements.•To use equality and relational operators to compare operands.•To use message dialogs to display messages.

Visual Basic 2005

Page 39: MELJUN CORTES

OverviewOverview

In this chapter, we introduce Visual Basic programming with program code and present examples to demonstrate how programs can display messages and obtain information from the user at the keyboard for processing

INTRODUCTION 39

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 40: MELJUN CORTES

Displaying a Line of TextDisplaying a Line of Text

Simple Visual Basic Program

INTRODUCTION 40

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 41: MELJUN CORTES

Creating A Console Application in Creating A Console Application in Visual Basic 2005Visual Basic 2005

Creating the console application

INTRODUCTION 41

Introduction to the Visual Basic Programming

Ensure that ConsoleApplication is selected

Type the projectname

Click Ok to createA new project

Visual Basic 2005

Page 42: MELJUN CORTES

Creating A Console Application in Creating A Console Application in Visual Basic 2005Visual Basic 2005

IDE with an open console application

INTRODUCTION 42

Introduction to the Visual Basic Programming

Code or editorwindow

Visual Basic 2005

Page 43: MELJUN CORTES

Creating A Console Application in Creating A Console Application in Visual Basic 2005Visual Basic 2005

Changing the name of the program file

INTRODUCTION 43

Introduction to the Visual Basic Programming

Click Module1.vbto display itsproperties

File Name property(file name can be

changed here)

Visual Basic 2005

Page 44: MELJUN CORTES

Creating A Console Application in Creating A Console Application in Visual Basic 2005Visual Basic 2005

Setting up the startup object

INTRODUCTION 44

Introduction to the Visual Basic Programming

Change the startupobject by selecting from Startup Object

drop-down list

Visual Basic 2005

Page 45: MELJUN CORTES

Creating A Console Application in Creating A Console Application in Visual Basic 2005Visual Basic 2005

IntelliSense feature of Visual Studio

INTRODUCTION 45

Introduction to the Visual Basic Programming

Partially-typed member

Member list

Highlighted member

Visual Basic 2005

Page 46: MELJUN CORTES

Writing Another Sample ProgramWriting Another Sample ProgramINTRODUCTION 46

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 47: MELJUN CORTES

ArithmeticArithmetic

The arithmetic operators are summarized below:

INTRODUCTION 47

Introduction to the Visual Basic Programming

VB Operation Arithmetic Operator

Algebraic Expression

VB Expression

Addition + f + 7 f + 7

Subtraction - p – c p – c

Multiplication * bm b * m

Division (floating point) / x/y or x÷y x / y

Division (integer) \ none v \ u

Modulus Mod r mod s r Mod s

Exponentiation ^ qp q ^ p

Unary minus - -e -e

Unary plus + +g +g

Visual Basic 2005

Page 48: MELJUN CORTES

ArithmeticArithmetic

Precedence of arithmetic operators

INTRODUCTION 48

Introduction to the Visual Basic Programming

Operator(s) Operation Order of evaluation (precedence)

^ Exponentiation Evaluated first. If there are several such operators, they are evaluated from left to right.

+,- Sign operations Evaluated second. If there are several such operators, they are evaluated from left to right.

*,/ Multiplication and Division

Evaluated third. If there are several such operators, they are evaluated from left to right.

\ Integer division Evaluated fourth. If there are several such operators, they are evaluated from left to right.

Mod Modulus Evaluated fifth. If there are several such operators, they are evaluated from left to right.

+,- Addition and Subtraction

Evaluated sixth. If there are several such operators, they are evaluated from left to right.

Visual Basic 2005

Page 49: MELJUN CORTES

Equality and Relational OperatorsEquality and Relational Operators

Equality and relational operators

INTRODUCTION 49

Introduction to the Visual Basic Programming

Standard algebraic equality operator

or relational operator

VB equality or relational

operator

Example of VB condition

Meaning of VB condition

Equality operators

= = x = y x is equal to y

≠ <> x <> y x is not equal to y

Relational operators

> > x > y x is greater than y

< < x < y x is less than y

≥ >= x >= y x is greater than or equal to y

≤ <= x <= y x is less than or equal to y

Visual Basic 2005

Page 50: MELJUN CORTES

Using a Message Dialog to Display a Using a Message Dialog to Display a MessageMessage

Visual Basic programs often use message dialog windows to display output

Visual Basic provides class MessageBox for creating message dialogs

INTRODUCTION 50

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 51: MELJUN CORTES

Using a Message Dialog to Display a Using a Message Dialog to Display a MessageMessage

Displaying text in a message dialog

INTRODUCTION 51

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 52: MELJUN CORTES

Using a Message Dialog to Display a Using a Message Dialog to Display a MessageMessage

Displaying text in a message dialog

INTRODUCTION 52

Introduction to the Visual Basic Programming

Visual Basic 2005

Page 53: MELJUN CORTES

End of IntroductionEnd of IntroductionINTRODUCTION 53

Introduction to the Visual Basic Programming

Visual Basic 2005