30
Visual Basic .NET Programming The Visual Studio .Net IDE Differences between VB.Net and VB6 IDE Creating Visual Basic .NET Projects Setting Project References The Visual Studio .Net IDE * Property of STI Page 1 of 30 Using Development Environment Features Debugging Applications

MELJUN CORTES Vb.net the vb .net ide

Embed Size (px)

Citation preview

Page 1: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

The Visual Studio .Net IDE

� Differences between VB.Net and VB6 IDE

� Creating Visual Basic .NET Projects

� Setting Project References

The Visual Studio .Net IDE * Property of STIPage 1 of 30

� Using Development Environment Features

� Debugging Applications

Page 2: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� There is one IDE for all .NET projects

� Solutions can contain multiple

programming language

� The IDE is customizable through “My

Profile”

Differences between VB.Net and VB6 IDE

The Visual Studio .Net IDE * Property of STIPage 2 of 30

Profile”

� The IDE has a built-in Internet browser

Page 3: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� Start Window

The IDEStart Window

The Visual Studio .Net IDE * Property of STIPage 3 of 30

Page 4: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Choosing a Project Template

� Visual Studio Templates

The Visual Studio .Net IDE * Property of STIPage 4 of 30

Page 5: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Choosing a Project Template

Template Use this template to create:

Windows

Applications

Standard Windows-based

applications

Class Library

Class libraries that provide similar

functionality to Microsoft Active X

DLL

The Visual Studio .Net IDE * Property of STIPage 5 of 30

DLL

Windows

Control

Library

User-defined Windows control

projects

Web Control

Library

User-defined Web controls that

can be reused on Web page

Console

Application

Console application that will run

from a command line

Windows

Service

Windows services that will run

continuously regardless of whether

a user is logged on or not

Page 6: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Analyzing Project Structures

� What follows are the files contained in

every VB .Net project:

� Solution files (.sln, 。suo)

� Project files (.vbproj)

The Visual Studio .Net IDE * Property of STIPage 6 of 30

� Local project items (.vb)

� Web project items (.aspx, .asmx, .asax)

Page 7: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Creating VB .NET Projects

� Assemblies

� one or more files that make up a Visual

Studio Application

� key concept in .NET development

The Visual Studio .Net IDE * Property of STIPage 7 of 30

� serve as building block for all .NET

applications.

� Namespaces

� used in .NET Framework assemblies

� organize classes, interface and modules

into a structure that is easy to understand

Page 8: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Creating Windows Application Project

� File > New Project

� select the Windows Application template

� type a name for the project then click OK

The Visual Studio .Net IDE * Property of STIPage 8 of 30

Page 9: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Setting Project References

� Adding References

� select the current project in Solution

Explorer then Project > Add Reference

The Visual Studio .Net IDE * Property of STIPage 9 of 30

� click .NET, COM, or Projects tab

� locate the required component in the list

• you may click the Browse tab to locate the

file

� repeat step 3 for all the components you

require, and then OK

Page 10: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Setting Project Properties

� Application Property Settings:

� Assembly name

� Root namespace

� Application type

� Startup object

� Assembly Information

The Visual Studio .Net IDE * Property of STIPage 10 of 30

Page 11: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Setting Project Properties

� Compile Property Settings:

� Build output path

� Option explicit

� Option Strict

The Visual Studio .Net IDE * Property of STIPage 11 of 30

Page 12: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� Solution Explorer

� Object Browser

� Server Explorer

IDE Features

The Visual Studio .Net IDE * Property of STIPage 12 of 30

� Task List

� Dynamic Help

Page 13: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Form Window

� where the controls that make up the user

interface are placed

The Visual Studio .Net IDE * Property of STIPage 13 of 30

Page 14: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Code Window

� where the codes for forms, events and

methods are written, displayed and

modified

The Visual Studio .Net IDE * Property of STIPage 14 of 30

Page 15: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Toolbox

� contains the objects and controls that can

be added to Windows Forms

The Visual Studio .Net IDE * Property of STIPage 15 of 30

Page 16: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Component Tray

� where non-visual components that do not

appear at run time are stored

The Visual Studio .Net IDE * Property of STIPage 16 of 30

Page 17: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Properties Window

� where properties of an object selected at

design time are modified

The Visual Studio .Net IDE * Property of STIPage 17 of 30

Page 18: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Auto Hide

� “hides” windows from the main IDE

� click the Auto Hide button on the

toolbar to toggle Auto Hide on and off

The Visual Studio .Net IDE * Property of STIPage 18 of 30

� Tabbed Documents

� this mode adds a tab to the top of the

main window for each open document or

file

� click on the tab that represents the

document to switch between open

documents

Page 19: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

IDE Features

� Multiple Documents

� MDI – Multiple Document Interface

� display multiple documents simultaneously

� to work in an MDI environment

• Tools > Options

The Visual Studio .Net IDE * Property of STIPage 19 of 30

• click Multiple documents on the Window

layout section

• click OK

� Dockable windows

� all windows within the IDE can be docked

to any edge of the IDE by dragging them to

any location

Page 20: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� displays project hierarchy, project

references, project items and any

subfolders that contain project items

Solution Explorer

The Visual Studio .Net IDE * Property of STIPage 20 of 30

Page 21: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� “Show all Files” mode

� click the Show all Files button to

display the hidden files or those marked as

excluded from the project

� Manipulating Projects

Solution Explorer

The Visual Studio .Net IDE * Property of STIPage 21 of 30

� Manipulating Projects

� Drag-and-drop editing

� Context menus

Page 22: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Server Explorer

� Managing Data Connections

� View > Server Explorer

The Visual Studio .Net IDE * Property of STIPage 22 of 30

� Adding a connection

� click Connect to Database on the

Server Explorer toolbar

Page 23: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Server Explorer

� select Data Source from the Data Source

box then click the Continue button

The Visual Studio .Net IDE * Property of STIPage 23 of 30

� click Browse button to select a database

file and enter the corresponding User

name and Password of the database

� click Test Connection to check if the

connection was successfully done

Page 24: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� View > Object Browser

Object Browser

The Visual Studio .Net IDE * Property of STIPage 24 of 30

Page 25: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� Using the VB .NET Object Browser, you

can:

� examine objects and their members within

a library

� access lower-level items

ObjectBrowser

The Visual Studio .Net IDE * Property of STIPage 25 of 30

� examine how the .NET Framework class

libraries use inheritance in their object

hierarchies

Page 26: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� tasks are kept in the .suo project file so

that information are not lost when the

Visual Studio .NET is closed

� View > Other Windows > Task List

Task ListWindow

The Visual Studio .Net IDE * Property of STIPage 26 of 30

� Adding Task List

� type in the top row that is always visible to

the Task List window

� build your application to automatically add

tasks to the list

� create comments in the code that use

specific token strings defined in the Options

dialog box

Page 27: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

� displays appropriate Help links to the .NET

Help files

� changes topic depending on the location

of the cursor

� Help > Dynamic Help

Dynamic Help

The Visual Studio .Net IDE * Property of STIPage 27 of 30

CheckBox

selected

from the

Toolbox

Button

selected

from the

Toolbox

Page 28: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Designing VB .NET Application

� Steps in creating a program in VB .Net.

� Create the interface

� Set properties

� Write the code

The Visual Studio .Net IDE * Property of STIPage 28 of 30

� Write the code

Page 29: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Debugging Applications

� Setting Breakpoints

� Ways

• click the margin to the left of the code window

on the line containing the statement where

debugger will halt

• DebugDebugDebugDebug > New BreakpointNew BreakpointNew BreakpointNew Breakpoint

• place the cursor on the line where you want

the debugger to halt. Press <F9> to switch the

The Visual Studio .Net IDE * Property of STIPage 29 of 30

the debugger to halt. Press <F9> to switch the

breakpoint on and off.

� Debugging Code

� Step Into

� Step Over

� Step Out

Page 30: MELJUN CORTES Vb.net the vb .net ide

Visual Basic .NET Programming

Debugging Applications

� Sample Demonstration:

� create a new project

� double-click the form to go to Code

window

� type following code on the Private Sub

Form1_Load event handler:

Dim X As Integer

Dim Y As Integer

The Visual Studio .Net IDE * Property of STIPage 30 of 30

X = 10

Y = X – 5

MessageBox.Show(Y)

� place the pointer on the line Y = X – 5

then press <F9>

� press <F5>

� place the pointer on the Y variable

� press <F11> to Step into the code

� close the program