1 the visual studio.net and vb.net integrated development environment (ide)

41
1 The Visual Studio .NET and VB .NET Integrated Development Environment (IDE)

Upload: justin-davidson

Post on 24-Dec-2015

226 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

1

The Visual Studio .NET and VB .NET Integrated

Development Environment (IDE)

Page 2: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

2

Lesson A

A Tour of the Integrated Development Environment

Page 3: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

3

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

Page 4: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

4

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

Page 5: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

5

Start Page, New Project Dialog Box, with Windows Application Selected

Page 6: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

6

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

Page 7: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

7

New Project Dialog Box Showing the ASP .NET Web Application Selected

Page 8: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

8

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

Page 9: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

9

New Project Dialog Box with Console Application Selected Under Templates

Page 10: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

10

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

Page 11: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

11

Add New Item Dialog Box Showing All Local Project Items

Page 12: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

12

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

Page 13: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

13

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

Page 14: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

14

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

Page 15: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

15

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

Page 16: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

16

Viewing the Tab Order of the Village Housing Application

Page 17: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

17

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

Page 18: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

18

Property Pages - Common Properties -Build

Page 19: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

19

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

Page 20: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

20

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

Page 21: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

21

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

Page 22: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

22

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

Page 23: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

23

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

Page 24: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

24

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

Page 25: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

25

Lesson B

A First Windows Forms Application

Page 26: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

26

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

Page 27: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

27

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

Page 28: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

28

Completed frmTour at Design Time

Page 29: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

29

Completed frmWelcome

Page 30: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

30

Lesson C

A First Console Application

Page 31: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

31

Objectives

• Build a Visual Basic .NET Console application • Use the Visual Basic .NET random number

generator

Page 32: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

32

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

Page 33: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

33

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

Page 34: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

34

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

Page 35: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

35

Code to Produce 100 Random Index Values

Page 36: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

36

Console Results - 100 randomly Selected Index Values

Page 37: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

37

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

Page 38: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

38

Code to Read and Display Variables

Page 39: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

39

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

Page 40: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

40

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

Page 41: 1 The Visual Studio.NET and VB.NET Integrated Development Environment (IDE)

41

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