Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Overview 1
Multimedia: Tour of Visual Studio .NET 2
Lesson: Basic .NET Concepts 3
Lesson: Exploring the Development
Environment 17
Lesson: Creating a Visual Basic .NET
Project 30
Review 37
Lab 1.1: Creating Your First Application 39
Module 1:
Getting Started
Information in this document, including URL and other Internet Web site references, is subject to
change without notice. Unless otherwise noted, the example companies, organizations, products,
domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious,
and no association with any real company, organization, product, domain name, e-mail address,
logo, person, place or event is intended or should be inferred. Complying with all applicable
copyright laws is the responsibility of the user. Without limiting the rights under copyright, no
part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or
otherwise), or for any purpose, without the express written permission of Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual
property rights covering subject matter in this document. Except as expressly provided in any
written license agreement from Microsoft, the furnishing of this document does not give you any
license to these patents, trademarks, copyrights, or other intellectual property.
2002 Microsoft Corporation. All rights reserved.
Microsoft, MS-DOS, Windows, Active Directory, ActiveX, bCentral, BizTalk, FrontPage,
IntelliSense, JScript, Microsoft Press, MSDN, MSN, Outlook, PowerPoint, Visual Basic,
Visual C++, Visual C#, Visual Studio, Win32, and Windows Media are either registered
trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their
respective owners.
Module 1: Getting Started iii
Instructor Notes
This module introduces Microsoft Visual Basic .NET and explains how it fits
into the Microsoft .NET platform. The module also explains how to use the
programming tools in Microsoft Visual Studio .NET and provides enough
practice to enable students to create their first application in Visual Basic .NET.
After completing this module, students will be able to:
! Start a Visual Basic .NET project that is based on the Microsoft Windows
Application template.
! Use the standard toolbar, programming tools, and programming windows in
the development environment to work with applications.
! Create a simple application in Visual Basic .NET.
To teach this module, you need the following materials:
! Microsoft PowerPoint file 2559B_01.ppt
! Multimedia demonstration file 2559B_01d005.wmv
To prepare for this module:
! Read all of the materials for this module.
! Review the multimedia demonstration.
! Complete the practices and lab.
Presentation and
practices:
90 minutes
Lab:
30 minutes
Required materials
Preparation tasks
iv Module 1: Getting Started
How to Teach This Module
This section contains information that will help you to teach this module.
Multimedia: Tour of Visual Studio .NET
This module begins with a multimedia demonstration that is a conceptual
organizer for the key concepts and tasks taught in the module. This
demonstration prepares students to learn about and work in the Visual Studio
.NET development environment.
To run this demonstration, click the icon in the center of the slide for this topic.
If you prefer, the steps for you to perform this multimedia demonstration as an
instructor-led demonstration are included in the Demonstrations section of the
instructor notes.
For information about the correct settings for optimal viewing of the
multimedia demonstrations, see the Course Preparation Checklist enclosed in
the Trainer Kit.
You might find it helpful to keep the demonstration application open
while teaching the module content. You can switch back and forth between the
PowerPoint slides and the application to demonstrate individual topics.
Lesson: Basic .NET Concepts
This section describes the instructional methods for teaching each topic in this
lesson. As you present each topic, open Visual Studio .NET and demonstrate
how to do each of the tasks that the students will need to perform in the
practice.
This topic provides a broad overview of the key elements in the .NET platform
and how they work together to create unprecedented user experiences. Most of
the information in the topic is provided as reference material. In the lecture,
focus on the role of Visual Studio .NET as one of the tools specifically
designed to create solutions for the .NET platform. Get the students excited
about how they can participate in this new generation of software by learning
how to create applications in Visual Basic .NET.
Discuss the case study as an example of how .NET is helping companies solve
problems. You should spend no more than five minutes on this topic. At the end
of the course, you can revisit this topic and the next one to synthesize
everything that students have learned.
This topic explains how applications created in Visual Basic .NET interact with
the Microsoft .NET Framework. Keep the discussion focused on how the class
library provides standard functionality to all .NET-based applications
regardless of the language in which they are writtenand how the common
language runtime ensures that code written in Visual Basic .NET will work on
any .NET-based service or device. For entry-level programmers, most of the
detail in this topic is provided for reference only. You should spend no more
than 10 minutes on the first two topics in this lesson.
Note
What Is the .NET
Platform?
How the .NET
Framework Works
Module 1: Getting Started v
The important message to convey in this topic is that the development
environment is now the central place for creating all parts of a solution,
including Windows Forms applications, components, Web Forms applications,
and XML Web services. The focus of this course is Windows Forms
applications.
You should be able to teach this topic quickly. Ensure that students are aware
that the Visual Studio Start Page contains links that they can use to perform
many types of research. The Online Community pane was one of most popular
features with beta testers, so if you have time, demonstrate how to participate in
a newsgroup in the Online Community.
The key point of this topic is to give students a clear understanding of what a
template is and what it provides to the developer. Mention that this course
primarily covers how to create Windows Forms applications, though it includes
a brief introduction to Web Forms applications that use XML Web services. If
students are interested, refer them to other courses that teach how to create
other types of applications.
Demonstrate how to start a new Visual Basic .NET project, and briefly talk
about the many project types and templates when you encounter the New
Project dialog box.
Show how to open and close Solution Explorer, and briefly examine the files
that are a standard part of every Visual Basic .NETbased solution. Students
might be confused by the different tabs in the upper corner of the window, so
explain that these are for different views of the files and that they will be
explained in more detail later in the course. You can point out that the Index,
Contents, and Search windows for the product documentation sometimes
appear in the Solution Explorer area, but you will be talking more about this in
the next lesson.
Before students start the practice, explain the difference between debug and
release builds. You might want to show students how to locate the release
executable file. Clarify which file names are changed when you rename and
save a project. This practice is designed to take approximately 10 minutes.
Lesson: Exploring the Development Environment
This section describes the instructional methods for teaching each topic in this
lesson. This lesson introduces the main features in the development
environment that are used to create and work with Windows Forms
applications. As you present each topic in this lesson, open Visual Studio .NET
and demonstrate how to do each of the tasks that the students will need to
perform in the practice.
Demonstrate how to access common commands such as Open, Save, Start,
Break, and End from both the menu bar and the toolbars. Show how to use the
View menu to open and close the various toolbars. Finally, show how to move,
dock, and undock toolbars in general.
Toolbox behavior can be confusing, so spend a little time showing students how
to open, close, hide, and reopen the Toolbox. Demonstrate the pushpin
functionality and ensure that students know that the Toolbox does not appear
until you open a new or existing application.
What Is Visual Studio
.NET?
How to Use the Start
Page
What Is an Application
Template?
How to Use Solution
Explorer
Practice: Working with a
Visual Basic .NET
Project
Menus and Toolbars
The Toolbox
vi Module 1: Getting Started
Explain the elements of a new form, including the title bar, control box, and
Maximize, Minimize, and Close buttons. Place a control from the Toolbox on
the form to demonstrate how the design surface works, but do not spend time
explaining how to work with controls because this will be covered in detail in
the next lesson and in even more detail in the next module.
Open the Code Editor for a new form and show how to switch between Design
view and the Code Editor. You can mention that the automatically generated
code provides standard Windows applications functionality, but avoid going
into detail about namespaces and classes. This will be covered later and will
probably just confuse students at this point in the course.
Find and change the Text property of a new form. Explain that the Properties
window provides an easy way to define the characteristics for the form and the
user interface.
Demonstrate how to open and close the Task List, Output window, Class View
window, Command window, and Object Browser. Run a demonstration
application to show some sample data for the Task List and Output window.
Explain that both the Class View and Command windows will be covered in
more detail later in the course.
Students need to know how to use online Help to complete some of the labs and
practices in this course. As an interactive exercise, ask the students to name
some .NET topics that they would like more information about, and then
demonstrate all the ways that they can find information about that topic. One of
the best features in the Help system is the Dynamic Help window, so ensure
that students understand how it works.
Although this practice is straightforward and simple, students will be learning
several different features in Visual Studio .NET, so ensure that students are not
just following steps and that they understand the tasks they are performing.
Demonstrate some of the procedures while students are doing the practice if
you notice that some students need reinforcement before proceeding to the next
lesson. This practice is designed to take approximately 20 minutes.
Lesson: Creating a Visual Basic .NET Project
This section describes the instructional methods for teaching each topic in this
lesson. This lesson explains how to create a simple application in Visual Basic
.NET. The purpose of this lesson is to introduce students to the overall
programming process, not to get into the details of language syntax or
implementation. Students will practice the concepts and procedures taught in
this lesson by completing the lab.
This topic provides an overview of the entire development process, dividing the
process into seven distinct steps. Most of these steps are covered in detail later
in the course. This process is described to help students gain an understanding
of where they are in the process as they proceed through the course. Each
module overview slide also shows graphically what part of the development
process is covered in that module, and the terminology is consistent between
the module overview slides and this topic.
Emphasize that designing the application and gathering business requirements
are critical to the success of a project. Because this subject is outside the scope
of this course, you might want to identify appropriate courses and resources that
provide information about application analysis and design.
Windows Forms
Designer
Code Editor
Properties Window
Other Programming
Windows
Online Help System
Practice: Working in the
Development
Environment
The Development
Process
Module 1: Getting Started vii
This topic briefly introduces students to one of the key steps in the development
processcreating the user interface. Avoid going into too much detail in this
topic because there are similar topics in the next module that explain more
about control functionality and how to work with controls. Demonstrate that
you can double-click a control to add it to a form and then use standard
Windows functionality to move and size the control.
In this topic, use the same control you added in the previous topic and briefly
examine its properties. For this lesson, discuss only the Text property so that
students remain focused on the application development process rather than
trying to learn all about property settings and controls.
The key point of this topic is to emphasize the importance of writing code in the
overall application development process. Demonstrate how to open the Code
Editor and access the Click event for the control you have been working with in
the previous two topics. Do not write any code at this time, but explain where
the code for the event handler would go.
Emphasize that saving and testing is an ongoing part of the entire development
process. Talk about good programming practices and the role that testing plays
in iterative design and development. Explain again the difference between the
debug and release builds of the application, and emphasize that both builds
require testing.
Review
The review questions are mostly based on conceptual understanding and on
procedures that were covered thoroughly in the module. You can use a
discussion format to answer the questions so that everyone gets the benefit of
knowing the right answers.
1. If the students are not sure when they should use the Code Editor, explain
that they must write code for control events that are not part of the control
by default.
2. If students have difficulty with this question, review how code is processed
in the Visual Studio .NET environment. Visual Studio .NET compiles all
.NET-compliant code as Microsoft intermediate language (MSIL), so when
the runtime executes the code, it does not matter what language it was
written in.
3. This question may have many correct answers, but the one that students will
most likely give based on the module content is the one provided as the
right answer. If some students say that a design specification is the first step,
take the opportunity to emphasize how important the design phase is,
especially when programmers become more advanced.
4. This question will probably lead to questions about how to debug
applications. At this time, explain that there are some very good debugging
tools and error handling mechanisms, but that you will discuss them later.
5. There are two possible correct answers, but most students will choose
setting properties in the Properties window, not in the Code Editor. If
students find this concept confusing, explain that the Properties window
provides a simple user interface for creating the code that sets properties.
6. Use this question to start a discussion about good programming practices,
including design and testing.
How to Create the User
Interface
How to Set Control
Properties
How to Add Code for
Controls
How to Save, Run, and
Build the Application
viii Module 1: Getting Started
Lab 1.1: Creating Your First Application
Before beginning this lab, students should have completed all of the practices
and answered the review questions. Students will need to be able to perform
most of the tasks that they learned in the lessons and the practices. The lab is
simple but comprehensive. It leads students through the entire process of
creating an application, as described in the last lesson of this module.
Demonstrations
You can present the multimedia demonstration by running the multimedia file
provided with this module, or you can perform the demonstration yourself by
following these instructions.
For information about the correct settings for optimal viewing of the
multimedia demonstrations, see the Course Preparation Checklist enclosed in
the Trainer Kit.
Multimedia: Tour of Visual Studio .NET
This demonstration shows how to create a simple Visual Basic .NETbased
application by using Visual Studio .NET. It also demonstrates many of the
commonly used features of the development environment.
! Open Visual Studio .NET and use the Start Page
1. Start Visual Studio .NET.
Explain that the My Profile pane allows developers who are familiar
with previous versions of Visual Basic or Microsoft Visual C++ to
customize the development environment so that it is more like previous
versions. For this demonstration, do not change the default settings. Mention
that this pane appears when Visual Studio .NET is started for the first time
and is located on the Start Page thereafter.
2. Click Online Community. Explain that this pane provides easy access to
newsgroups related to .NET development.
3. Click Search Online. Explain that this pane provides easy access to the
Microsoft MSDN Online Library.
4. Click Get Started.
Note
Module 1: Getting Started ix
! Create a new project
1. On the Projects tab, click New Project.
2. In the New Project dialog box, in the Templates pane, click Windows
Application.
3. In the Name box, type ApplicationToExplore.
4. To set the location, click Browse and navigate to
install_folder\Democode\Mod01\Demo1, click Open, and then click OK.
Explain that a Visual Basic .NET Windows Application template
provides a single Windows form. The form is named Form1.vb, and it opens
in Design view.
! Examine Solution Explorer
1. In Solution Explorer, click Form1.vb, if it is not already selected.
Point out that the Form1.vb file was provided by the Windows Application
template used to create the project.
2. Right-click Solution ApplicationToExplore (1 project).
Point out that you can add other projects to the solution in addition to being
able to build and debug the solution from this shortcut menu.
3. Right-click ApplicationToExplore under the Solution node.
Point out that the shortcut menu for the project includes options for adding
references and other files to the project.
! Change the properties of the form
1. To make the form rectangular, drag the resize handle on the lower right.
2. In the Properties window, click BackgroundImage, and then click the
ellipsis button.
3. In the Open dialog box, navigate to install_folder\Democode\
Mod01\Demo1, click Blue hills.jpg, and then click Open.
! Add buttons to the form
1. Click the Button control in the Toolbox, and drag it onto the form.
2. Drag a second button onto the form.
Note
x Module 1: Getting Started
! Add code to a button
1. Double-click Button1 on the form.
Point out that the Code Editor opens. The window tab is named
Form1.vb*.
2. In the Code Editor, between Private Sub Button1_Click and End Sub
(where the cursor should be currently located), type the following code:
MessageBox.Show("Ready....Get Set.... Write Code!!!")
3. Go to Design view for Form1.vb.
4. Double-click Button2 on the form.
5. In the Code Editor, between Private Sub Button2_Click and End Sub
(where the cursor should be currently located), type the following code:
MessageBox.Show("Web....Windows...." & _
"Visual Studio .NET does it all!")
! Run and test the application
1. On the standard toolbar, click the Start button.
2. In the Form1 dialog box, click Button1.
3. In the message box, click OK.
4. In the Form1 dialog box, click Button2.
5. In the message box, click OK.
6. Close Form1.
! Use the Auto Hide feature
On the Output window title bar, click the pushpin icon.
Demonstrate how the Output window disappears when the cursor is
moved away from the window and opens again when the cursor is rested
over the Output tab.
! Undock a window
1. Click the pushpin icon on the Toolbox title bar.
2. Click the Toolbox title bar and drag the window into the middle of the
screen.
Note
Note
Module 1: Getting Started xi
! Dock a window
1. Click the title bar of the Toolbox and drag the window to the left side of the
Visual Studio .NET application window until the cursor is almost at the left
edge of the screen.
2. Click the pushpin icon in the Toolbox title bar to enable the Auto Hide
feature again.
! Save a project
On the standard toolbar, click the Save All button.
The location of the solution is set when the solution is created.
! Close a solution
On the File menu, click Close Solution.
The Projects tab of the Start Page will now display
ApplicationToExplore in the list of recent projects when the screen is
refreshed or the next time Visual Studio .NET is started.
! Quit Visual Studio .NET
On the File menu, click Exit.
The solution files for this demonstration are located in the
install_folder\Democode\Mod01\DemoSolution folder.
Note
Note
Solution files
Module 1: Getting Started 1
Overview
! Basic .NET Concepts
! Exploring the Development
Environment
! Creating a Visual Basic
.NET Project
Use Visual
Studio .NET
Access
Data
Debug
and Deploy
Write
Code
Create
Interface
Use Visual
Studio .NET
*****************************ILLEGAL FOR NON-TRAINER USE******************************
This module introduces Microsoft Visual Basic .NET and explains how it fits
into the Microsoft .NET platform. It explains how to use the programming tools
in Microsoft Visual Studio .NET and provides enough practice so that you can
create your first application in Visual Basic .NET.
After completing this module, you will be able to:
! Start a Visual Basic .NET project that is based on the Microsoft Windows
Application template.
! Use the standard toolbar, programming tools, and programming windows in
the development environment to work with applications.
! Create a simple application in Visual Basic .NET.
Introduction
Objectives
2 Module 1: Getting Started
Multimedia: Tour of Visual Studio .NET
*****************************ILLEGAL FOR NON-TRAINER USE******************************
This multimedia demonstration takes you on a tour through Visual Studio
.NET. It shows how to create a simple Visual Basic .NETbased application by
using Visual Studio .NET. It demonstrates many of the commonly used features
of the development environment.
Introduction
Module 1: Getting Started 3
Lesson: Basic .NET Concepts
?.NET
Platform?
?Visual Studio
.NET?
?Visual Basic
.NET?
?.NET
Framework?
?HELP!
.NET
*****************************ILLEGAL FOR NON-TRAINER USE******************************
Visual Basic .NET is the newest version of the Visual Basic development
system. Before you start creating applications in Visual Basic .NET, you will
find it useful to understand some basic .NET concepts.
This lesson includes the following topics and activities:
! What Is the .NET Platform?
! How the .NET Framework Works
! What Is Visual Studio .NET?
! How to Use the Start Page
! What Is an Application Template?
! How to Use Solution Explorer
! Practice: Working with a Visual Basic .NET Project
This lesson provides an overview of the .NET platform and how it benefits
developers. It explains how to use the programming tools in the Visual Studio
.NET development environment to create applications in Visual Basic .NET.
After completing this lesson, you will be able to:
! Describe the key elements of the .NET platform.
! Explain the benefits that the Microsoft .NET Framework offers to
developers.
! Describe the role of Visual Studio .NET and Visual Basic .NET in the .NET
platform.
! Use the Visual Studio Start Page to access developer news and to set user
preferences.
! Start a Visual Basic .NET project that is based on the Windows Application
template.
! Use Solution Explorer to examine solution files and code.
Introduction
Lesson agenda
Lesson objectives
4 Module 1: Getting Started
What Is the .NET Platform?
Developer
Tools
XML Web Services
Servers
Clients
User
Experiences
*****************************ILLEGAL FOR NON-TRAINER USE******************************
The .NET platform provides the foundation for the next generation of software
that connects disparate systems, information, devices, and users in a more
unified and personalized way. It includes XML Web services as the means to
enable different technologies to interoperate. It provides software developers
the tools and technology to quickly and efficiently deliver business solutions
that span multiple applications and multiple client devices across many
organizations. It enables users to control how, when, and what information is
delivered to them.
The following is an example of how the .NET platform can help companies
integrate solutions and share data to improve the user experience.
An airline partner approached a car rental company, one of the worlds largest
car rental companies, with the opportunity to link the companys reservations
system with the airline partners Web site. The challenge for the car rental
company was to determine how to easily transfer reservation requests and
related data between this large airline, which uses UNIX systems, and the
company, which primarily uses Windows technologies.
The car rental company chose to build its solution with .NET technologies and
XML Web services. The solution enabled the company to quickly build a
translation system between the UNIX system at the airline and the companys
VMS system. The solution was developed by two people in only two months
two to three times faster than the company had anticipated.
Using traditional methods of creating a unique solution for this particular airline
was certainly an option. But by building the system with XML Web services,
the car rental company is capable of extending its service to multiple airlines
and partners. If other partners or corporate customers want to connect directly
with the companys reservations systems, all the company needs to do is give
them the XML schema.
Introduction
Case study
Module 1: Getting Started 5
The .NET platform includes a comprehensive family of products created to
comply with XML and Internet standards. These products provide the following
components for working with XML-based solutions:
! Tools to develop solutions
! Servers to manage, build, and deploy solutions
! Services to integrate, connect, and reuse solutions
! Hardware and software clients to provide unprecedented user experiences
The following table provides definitions and examples for each of the key
elements in the .NET platform.
Element Definition Examples
Developer
tools
The programming interfaces and tools for
designing, creating, running, and deploying
solutions for the .NET platform.
.NET Framework
Visual Studio .NET
Servers The infrastructure for building, deploying,
and operating solutions for the .NET
platform.
Microsoft Windows 2000
Server
Microsoft .NET
Enterprise Servers
XML Web
services
A core set of predefined services that
perform common and routine tasks, and the
means for developers to develop their own
services.
Microsoft .NET My
Services
Clients Devices running on operating systems that
integrate and interact with all of the other
.NET elements.
Microsoft Windows CE
for handheld devices
Microsoft Windows XP
for computers
User
experiences
Traditional client software integrated with
XML Web services to present everything
users need in a way that makes sense to
them.
Future versions of
Microsoft bCentral
Microsoft MSN
Family of .NET products
Key elements
6 Module 1: Getting Started
How the .NET Framework Works
Visual Basic
Applications
Visual C#
Applications
Visual C++
Applications
.NET
Platform
Code
.NET Framework
Class Library
W
i
n
d
o
w
s
X
M
L
W
e
b
S
e
r
v
i
c
e
s
A
D
O
.
N
E
T
D
a
t
a
T
y
p
e
s
Common Language
Runtime
Source code compiles as MSIL
Source code compiles as MSIL
Programming Services
Programming Services
JIT compiler produces
machine language
JIT compiler produces
machine language
*****************************ILLEGAL FOR NON-TRAINER USE******************************
The .NET Framework is a set of programming services designed to simplify
application development in the highly distributed environment of the Internet.
The .NET Framework has two main components: the common language
runtime and the class library.
When you create a new Windows-based application in Visual Basic .NET, you
are provided with starter code that includes the System.Windows.Forms
namespace and the Form class. With this class, you can easily create windows,
buttons, menus, toolbars, and other screen elements. When you compile the
application, it is translated into the runtimes common language, Microsoft
intermediate language (MSIL). After the application is compiled, the runtime
manages the execution of the application.
The runtime includes a feature called just-in-time (JIT) compilation that
translates the MSIL code into the machine language of the system on which the
application will run. When a client device on the .NET platform launches the
Visual Basic .NET application, it starts running in the machine language of the
client system and can fully integrate and interact with other .NET-based
applications and services regardless of the language in which it was developed.
Introduction
How applications
interact with the .NET
Framework
Module 1: Getting Started 7
To understand how the .NET Framework works, you need to be familiar with
the following terminology:
! Class
A class is a named programming entity that comprises a common set of
methods, properties, and attributes. For example, Form is one of the classes
in the System.Windows.Forms namespace that is used to create Windows
Forms.
! Namespace
A namespace identifies a collection of related classes and/or other
namespaces in the .NET Framework. Examples of namespaces include the
following:
System
System.Windows.Forms
! Class library
The class library is a comprehensive object-oriented collection of reusable
classes that are organized by their functionality into hierarchical
namespaces. You can use the class library to develop applications ranging
from traditional client applications to applications based on the latest
innovations provided by Microsoft ASP.NET and XML Web services.
! Common language runtime
The common language runtime is the foundation of the .NET Framework. In
the .NET environment, programmers develop applications in the .NET-
compatible language of their choice, the code is compiled into MSIL, and
the runtime manages and runs the compiled code.
In addition to Microsoft languages such as Visual Basic, Microsoft
Visual C#