43
Chapter 1 Getting Started with VB .NET

Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

  • View
    317

  • Download
    7

Embed Size (px)

Citation preview

Page 1: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Chapter 1

Getting Started with VB .NET

Page 2: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 2

Objectives Learn about VB .NET and the

characteristics of a VB .NET solution Start and configure VB .NET Explore the elements of the

development environment Learn how to access Help Open a VB .NET solution Explore the tool windows and operating

modes of VB .NET

Page 3: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 3

Introducing Visual Studio .NET Visual Studio .NET is an integrated

development environment Development environment supports three

different languages Visual Basic Visual C++ C# (pronounced C sharp)

New to Visual Studio .NET Note that Visual Interdev is obsolete. Functionality

included with other Visual Studio .NET products

Page 4: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 4

Introducing Visual Studio.NET Applications (called solutions) developed using

a developer interface called the Microsoft Development Environment (MDE)

VB .NET supports different types of applications created with the following tools

Windows Forms used to create desktop applications

Web Forms used to create programmable Web pages

Web Services process client – server requests

Page 5: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 5

? Programming Languages Programming language are made up of words

forming statements A Statement expresses a complete thought or

idea Similar to an English sentence

Statements grouped into procedures A procedure is similar to a paragraph in English

Procedures grouped into a module Modules contain one or more procedures Modules correspond to physical disk files Module files have the suffix .vb.

Page 6: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 6

? Programming Languages A program contains statements,

grouped into procedures, in one or more modules VB .NET calls a program a solution

Each solution is stored in its own folder Solution folder contains sub folder Solution folder contains all of the files that

make up the solution

Page 7: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 7

Program Relationships

Public Class frmMain

Inherits System.Windows.Forms.Form

Private components = New System.ComponentModel.Container

End Class

Public Class frmDialog . . .End Class

Public Sub New()

End Sub

Public Sub InitializeComponent()

End Sub

MyBase.New()InitializeComponent()

Me.Text = "Chapter 1 – Completed Example

Procedure

Procedure

Module filefrmMain.vb

Module filefrmDialog.vb

Executablestatements

Executablestatement

Page 8: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 8

Types of Statements Declaration statements define the names of data

and procedures The following statements declare a variable and a

procedure

Private mstrCustomerName As String

Private Sub InitializeComponent()End Sub

Executable statements perform a specific action The following statement closes the form named

frmMain

frmMain.Close()

Page 9: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 9

Syntax Programming statements adhere to rules

known as syntax Statements must be exactly correct VB .NET cannot interpret statements with

typographical or spelling errors Incorrect statements will cause a syntax error

Syntax errors occur when a statement violates the rules of the language

Private mstrCustomerName As StrungfrmMain.Closed()

Private mstrCustomerName As StrungfrmMain.Closed()

Page 10: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 10

VB .NET Programming Concepts

VB .NET solutions have the same characteristics as other programs

Window is a rectangular area on the desktop Win Form (form) contains buttons and textboxes

Buttons, textboxes, and the form itself are all objects

Solutions contain 1 or more forms Collection of forms, buttons, and textboxes form

the user interface User interface represents what the user sees

and how the user interacts with the solution

Page 11: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 11

Object Oriented Terms Information hiding – Expose only essential

information and hide inner logic Encapsulation – Integrate (package) data

and processes that act on data together Inner logic is hidden from the developer

Inheritance – Create new objects from existing objects

Inherit one form from another form Polymorphism – Multiple procedures of the

same name perform different tasks Capable of taking many forms

Page 12: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 12

Object Oriented Terms Programming object mimics the behavior of a

real-world object Buttons on a form perform a task when clicked

Some objects are visible to the user – others are not

Objects are created from classes Multiple objects can be created from the same class.

For example, create multiple buttons on a form A class is a blueprint (template) for an object

Buttons on a form created from the Button class TextBoxes created from the TextBox class

Page 13: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 13

Internal View of a VB .NET Solution An object has:

Predefined behaviors or settings called properties Properties exist to define the size and position of a

button on a form, for example They are like adjectives they describe the object

Methods represent the actions an object can perform

They are like verbs they perform an action Events allow messages to be sent to a solution

Write code in event handlers also known as event procedures

When the user clicks a button, statement in the corresponding event handler execute

Page 14: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 14

Internal View of a VB .NET Solution

We use controls to create objects on a form A control created on a form is called a control

instance Button control is a button the user can click Label control displays text but cannot receive

input OpenFileDialog control displays a standard

dialog box allowing user to select a file PictureBox control displays pictures

All control instances are created from their respective class

Page 15: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 15

Sample of VB .NET Controls

Label control instance to display a descriptive prompt

Label control instance to display file name

PictureBox control instance to display graphical image

Buttons when clicked perform an action

OpenFileDialog control instance has no visual interface and appears in a tray at the bottom of the form

Page 16: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 16

Starting VB .NET

Start button

Microsoft Visual Studio.NET 7.0

Page 17: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 17

Configuring VB .NET VB .NET supports two operating modes

Tabbed documents environment Docked windows appear along edge of the MDE

(?) Docked windows can be temporarily hidden Floating windows appear anywhere on the

desktop Windows can be autohidden along any edge of

the MDE Multiple document interface

Appearance similar to Excel

Page 18: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 18

Configuring VB .NET On the Menu bar, click Tools, and then

click Options to display Options dialog box General tab sets environment (tabbed

documents or MDI mode) Projects and Solutions tab sets default

folder for projects and when changes are saved

Page 19: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 19

VB .NET Options Dialog Box – General Tab

Select folder

Active page highlighted

Page 20: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 20

VB .NET Options Dialog Box – Projects and Solutions Tab

Default project location

Page 21: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 21

VB .NET Window TypesDocked window

Document window

Autohidden window

Floating window

Page 22: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 22

Configuring the Menu Bar and Toolbar Multiple regions display toolbars

Regions appear along any edge of the MDE Individual toolbars can be hidden or made visible

depending on task at hand Use Customize dialog to configure toolbars

Floating toolbars appear anywhere on the desktop

Docked toolbars anchored along any edge of the MDE

Usually they appear below the menu bar

Page 23: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 23

Docked and Floating Toolbars

Docked toolbar

Floating toolbar

Toolbars docked along bottom of MDE

Page 24: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 24

Document Windows Appear on group tabs and correspond to the

individual files that make up a solution Win Form Designer used to create the user

interface Code Editor used to write statements in event

handlers Only one document window visible at a time Select window on group tab to activate desired

document window Buttons to the right of a group tab navigate

between document windows and close them

Page 25: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 25

Tool Windows The same tool windows are used in the

creation of all VB .NET solutions Solution Explorer groups all elements needed to

build and run a solution Properties window allows developer to manage

the appearance of each object Help windows are also tool windows

Tool windows can be: Docked – appearing along an edge of the MDE Autohidden – hidden along an edge of the MDE Floating – appearing anywhere on the desktop

Page 26: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 26

Document Windows & Tool Windows

Document windows appear on tab group

Close active document window

Solution Explorer is a tool window (appearing as a docked window

Page 27: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 27

Configuring Tool Windows Make a window float by right-clicking on the

title bar and select Floating Autohide a window by first docking the

window. Right-click the title bar and select Autohide

Dock a window by right-clicking the title bar and select dockable. Drag the window to an edge of the MDE

Configure windows as desired so that they best fit your needs

Page 28: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 28

Configuring Tool Windows

Docked window

Autohidden windows appear along an edge of the MDE

Page 29: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 29

Getting Help VB .NET supports four primary help windows

Index – alphabetical list of contents Contents – table of contents organized by topic Search – locate topics by keyword Dynamic Help – new to .NET

Display topics based on active window and current task

Topics that appear in the Dynamic Help window will change as you navigate from window to window

Help filters restrict information displayed

Page 30: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 30

Help – Index

Filter applied

Index tab

Applicable topics

Page 31: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 31

Help – Contents

Topic

Book expanded

Page 32: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 32

Help – Search

Search results

Search text

Page 33: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 33

Help – Dynamic Help

Dynamic Help Window

Page 34: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 34

Opening a VB .NET Solution Click File, and then click Open

Solution

Enter solution name

Select folder

Click to Open solution

Page 35: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 35

Organization of a VB .NET Solution

Solution file is at the heart of the application Controls how solution will be translated into

executable file Controls how application will be distributed File suffix is .sln

Solution file references one or more project files which:

Store global information List the other files in the project List references to namespaces

Page 36: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 36

Form Modules Projects can contain multiple forms Each form stored in a form module

Form module contains code to create control instances

Also contains code written by the developer to perform tasks

File suffix is .vb Do not change file suffix or VB .NET will not

be able to locate files

Page 37: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 37

Elements of a Solution

solution filesolution file

form module frmMain.vbform module frmMain.vb

form module frmDialog.vbform module frmDialog.vb

class module clsDemo.vbclass module clsDemo.vb

standard module stdDemo.vbstandard module stdDemo.vb

Bin folder contains compiled solutionBin folder contains compiled solution

Obj folder contains temporary filesObj folder contains temporary files

solution itemssolution items

text filetext file

icon filesicon files

miscellaneous filesmiscellaneous files

project fileComplete01.vbproj

project fileComplete01.vbproj

Page 38: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 38

The Solution Explorer Groups projects

and modules comprising a solution

Page 39: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 39

Properties Window Property is a characteristic of an object

Color, caption, screen location Set properties using the Properties window

Name column lists property Value column contains current value Display properties alphabetically or by

category Description of selected appears at the bottom

of the window Description section may be hidden

Page 40: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 40

Properties Window (2)

Object list boxObject list box

Selected Font property has subproperties

Selected Font property has subproperties

Description areaDescription area

Toolbar areaToolbar area

Page 41: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 41

Toolbox

Visual controls appear in the Toolbox

Visual controls appear in the Toolbox

Page 42: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 42

Operating Modes Three operating modes

In run mode VB .NET is executing the program

Program appears as the user will see it In design mode you assume the role of the

developer In break mode solution is temporarily

suspended Use for debugging Refer to Appendix A for information on

debugging

Page 43: Chapter 1 Getting Started with VB.NET. Slide 2 Objectives Learn about VB.NET and the characteristics of a VB.NET solution Start and configure VB.NET Explore

Slide 43

Running a Solution Press Start button on the Debug toolbar

Solution runs as the user will see it Press Stop Debugging button on the

Debug toolbar to end the solution and return to design mode