The Visual Studio .NET and VB .NET Integrated Development

advertisement

The Visual Studio .NET and VB

.NET Integrated Development

Environment (IDE)

1

Lesson A

A Tour of the Integrated

Development Environment

2

Objectives

• Identify the three principal categories of Visual Basic

.NET applications:

– Windows Forms applications

– Web Forms applications

– Console applications

• Navigate through the Visual Studio .NET Integrated

Development Environment’s (IDE) Main menu and toolbars

• Understand the purpose of other major components of the IDE:

– Code window, Class view

– Task List, Output window

– Server Explorer, and Help screens

• Identify some of the key differences between Visual

Basic .NET and earlier versions of Visual Basic

3

A Tour of the Integrated Development

Environment

• Understanding Application Categories

– The FGDT will develop three types of applications:

• Windows Forms applications

• Web Forms applications

• Console applications

• Understanding Visual Basic .NET Windows Forms

Applications

– User interface

• Contained within traditional windows and the application executes entirely on the local machine

– Any application running in a stand-alone environment is a good candidate for development as a Windows Forms application

4

Start Page, New Project Dialog Box, with

Windows Application Selected

5

Understanding Visual Basic .NET Web

Forms Applications

• Visual Basic .NET Web Forms application

– Uses the techniques and protocols of the World Wide

Web

– Interface is designed as an HTML or XML document

– End user’s Web browser renders the HTML/XML/ASP document on the local machine

– Application executes mostly on a server

– Data access occurs over a network through an XML

Web service

– Technology can also be applied to applications on a stand-alone machine

6

New Project Dialog Box Showing the ASP

.NET Web Application Selected

7

Understanding Visual Basic .NET

Console Applications

• Visual Basic .NET Console application

– Text-only application

– Compiled into an executable

– Run from a command prompt

• Console applications

– Support system utility functions

– More useful to systems programmer than applications programmer

8

New Project Dialog Box with Console

Application Selected Under Templates

9

Understanding the Main Menu

• Main menu

– Provides access to all the items you need in the IDE

• Using the File Menu

– New

• Opens a new project, file, or blank solution

– Open

• Opens an existing project or file

– Close

• Closes the file currently displayed in the main window

– Add New Item

• Opens the Add New Item dialog box

10

Add New Item Dialog Box Showing All

Local Project Items

11

Using the File Menu (Continued)

• Add Existing Item

– Adds an existing file to the current project

• Add Project

– Adds another project to the current solution

• Open Solution

– Opens a new solution

• Close Solution

– Closes the current solution

12

Using the File Menu (Continued)

• Save, Save As, Save All

– Saves currently selected component

– Saves currently selected component under different name or in different location

– Saves all components

• Source Control

– Not installed in Visual Studio .NET Professional Edition

– Allows organization to control multiple versions of software

• Page Setup and Print

– Selects settings for printing source code

• Recent Files and Projects

– Shortcut for opening the most recently opened files and projects

• Exit

– Exits Visual Studio .NET

13

Using the Edit Menu

• Insert File As Text

– Useful if you have saved a block of code as a text file

• Advanced

– Used for formatting code blocks

• Bookmarks

– Where you place your reminders and locators

• Outlining

– Enables you to create an outline for code

• IntelliSense

– Provides automatic statement completion and immediate assistance while coding

14

Using the View Menu

• Web Browser | Show Browser

– Displays the most recent HTML page

• Other Windows | Object Browser

– Displays the objects in the active project or the available objects in Visual Studio .NET

• Other Windows | Output

– Displays output (error) messages from the most recent compilation

• Tab Order

– Toggle for displaying the TabIndex property of every control on the currently displayed form

• Show Tasks

– Navigates among the tasks in the project Task List

• Toolbars

– Displays a submenu with 24 toolbars

15

Viewing the Tab Order of the Village

Housing Application

16

Using the View Menu (Continued)

• Full Screen

– Enables you to toggle the main window between full screen and Normal view

• Navigate Backward or Navigate Forward

– Changes main window display to previous display or returns to current display

• Property Pages

– Opens the Property Pages dialog box

• Application icon property

– Designates an icon to represent the project while it is running

• Option Explicit

– Requires that all variables be explicitly declared

• Option Strict

– Requires that all narrowing conversions be explicitly declared and that late bindings not be allowed

• Option Compare

– Allows settings of Binary (the default) or Text

17

Property Pages - Common Properties -

Build

18

Understanding the Main Menu

(Continued)

• Exploring the Project Menu

– Under the Project menu, Add New Item and Add Existing Item duplicate selections available in the File menu

– Exclude From Project removes currently selected component from current project

• Understanding the Build Menu

– Menu is useful when you need to compile a solution without executing it

19

Understanding the Debug Menu

• Breakpoint

– A place in your code where program execution is suspended (not terminated)

• Debug selections

– Windows | Breakpoints

– Windows | Autos

– Windows | Immediate

– Start

– Continue

– Stop Debugging

– Step Into

– QuickWatch

– Clear All Breakpoints

– Disable All Breakpoints

20

Exploring the Help Menu

• Dynamic Help

– Displays a short list of topics related to whatever you are currently doing in the IDE

• Contents

– Opens the table of contents for the Visual Basic .NET Help collection

• Index

– Opens a search frame that enables you to enter a keyword and look for that keyword throughout the Help Collection Index

• Search

– Opens a search frame that enables the user to enter a word and find it anywhere in the Help collection

21

Understanding Other IDE Components

• Understanding the Main Window

– Tabs at the top of the screen space identify open windows

• Initial choices include the Start Page, the Code window, the

Designer window, and the current Help screen

• Understanding Toolbars

– Toolbars provide a one-click shortcut to menu selections

– Standard toolbar always visible

• Understanding the Class View

– Class view enables you to examine all the symbols used in your application, or available to your application

22

Understanding Other IDE Components

(Continued)

• Understanding the Properties window

– Read-only properties are disabled

– Expansion button appears to the left of group-level properties

– Complex properties can be set by clicking an ellipsis

– When you can select from a list of property setting choices, the

Settings box is a combo box with a down arrow that lists the choices

– Property window has its own toolbar

• Understanding the Output window

– Output window displays messages to you from the IDE

23

Understanding Other IDE Components

(Continued)

• Understanding the Toolbox

– Toolbox is subdivided by tabs, and the particular tabs available depend on the contents of the main window

• Data tab

• Components tab

• Windows Forms tab

• Understanding Server Explorer

– Server Explorer opens and manages data connections to both internal and external databases and related services

24

Lesson B

A First Windows Forms

Application

25

Objectives

• Make practical use of the View menu and the

Debug menu

• Create controls on a Windows form using the

Toolbox

• Develop and implement a splash screen, both as a Windows Forms application and as a Web

Forms application

26

Experimenting with the Debug Menu

To experience the Debug menu within the Visual Studio IDE:

1.

Open the VisualTour project (if necessary). In Solution Explorer, click frmTour.vb

, and click the View Code button to open the Code window

2.

At the end of the Private Sub btnClickMe_MouseEnter event procedure, click anywhere on the last line (End Sub), and press F9

3.

Click Debug on the Main menu, and note the menu items available at design time. Click Windows on the Debug menu, and note the menu items available

4.

In Form Designer, click Timer1 in the tray underneath the form. Then click the

Enabled property in the Properties window, and set it to False

5.

Select Start from the Debug menu, or click the Start button to initiate execution of the Visual Tour application

6.

Again, select Debug on the Main menu, and note the many different menu items available at runtime. Click Windows on the Debug menu, and note the menu items available

7.

From the Windows taskbar, click the Visual Tour running application. Move the cursor over the Touch Here button

27

Completed frmTour at

Design Time

28

Completed frmWelcome

29

Lesson C

A First Console Application

30

Objectives

• Build a Visual Basic .NET Console application

• Use the Visual Basic .NET random number generator

31

Building Random Numbers: a Console

Application

• Console application

– A way of experimenting with snippets of code, without having to design an entire GUI

– Output can be sent to the console object or to the

Debug object

– Write ( ) function writes to the specified device, but leaves the print cursor positioned immediately after the last character written

– WriteLine ( ) function writes to the specified device, and then writes a carriage return/linefeed sequence

32

Building Random Numbers: a Console

Application (Continued)

• Rnd( )

– A pseudorandom number generator

– Produces a random real number n such that 0 <= n < 1

– Works by performing a calculation on the previous number that it produced

• Random seed

– Used with the first Rnd( ) function call

– By default the seed is the same whenever a program begins execution

• Randomize( )

– Seeds the random number generator based on the setting of the system clock

33

Building Random Numbers: a Console

Application (Continued)

• Formula for converting the Rnd( ) return value to an integer within a specified range

– Int(Rnd() * (UpperBound – LowerBound + 1) +

LowerBound)

• Valuable feature in certain applications

– Generating the same sequence of random numbers each time a program runs, as Rnd( ) does

34

Code to Produce 100 Random Index

Values

35

Console Results - 100 randomly Selected

Index Values

36

Other Notes Concerning Console

Applications

• Console applications

– Often compiled and subsequently executed from the command prompt

• Output sent to the Console object appears in the command window

• Output sent to the Debug object is ignored and does not raise an exception

– If keyboard input is required

• ReadLine( ) function is employed

37

Code to Read and Display Variables

38

Summary

• Visual Basic .NET Windows Forms application

– Application involving a traditional Windows-style user interface

– Implemented entirely on a local computer

• Visual Basic .NET Web Forms application

– Application involving a Web-style interface

• Visual Basic .NET Console application

– Local, text-only application that runs from a command prompt

• Visual Basic .NET Integrated Development Environment

– Includes multiple views and windows

– Provides extensive debugging facilities

– Provides an extensive Help system

39

Summary (Continued)

• Conventional prefixes

– frm: Windows form

– web: Web form

– btn: Button

– lbl: Label

• Windows form properties

– Name, BackColor, BackgroundImage, ControlBox

– FormBorderStyle, Icon, Size, StartPosition, and Text

• In the Code Editor

– Class Name combo box identifies the objects in the form

– Method Name combo box lists the events and methods available to the currently selected object

• Web form properties

– Background, bgcolor, and pagelayout

40

Summary (Continued)

• Console applications

– Most useful for experimenting with program code

• Rnd ( ) and Randomize ( ) functions

– Provide the capability to generate and manage random numbers

• Output from Console application

– Normally sent to the Console object or to the Debug object

• Input in a Console application

– Obtained from the Console.ReadLine ( ) function

41

Download