Title: Getting Started with VB 'NET
1Chapter 1
- Getting Started with VB .NET
2Objectives
- 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
3Introducing Visual Studio .NET (1)
- 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
4Introducing Visual Studio.NET (2)
- 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
5Differences Between VB 6 and Visual Studio .NET
- VB 4, 5, and 6 were backward compatible
- VB .NET is not backward compatible
- VB 6 programs require significant modification to
run under VB .NET - VB .NET incorporates new object oriented
programming features - VB .NET adheres to the Common Language
Specification (CLS) for language interoperability - ADO.NET replaces ADO
- ADO.NET operates better with Web applications
6Facts About Programming Languages (1)
- Programming language 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.
7Facts About Programming Languages (2)
- 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
8Program Relationships
Public Class frmMain Inherits
System.Windows.Forms.Form Private components
New System.ComponentModel.Container End
Class
Module filefrmMain.vb
Public Sub New() End Sub
Procedure
MyBase.New()InitializeComponent()
Executablestatements
Public Sub InitializeComponent() End Sub
Procedure
Me.Text "Chapter 1 Completed Example
Executablestatement
Public Class frmDialog . . .End Class
Module filefrmDialog.vb
9Types of Statements
- Declaration statements define the names of data
and procedures - The following statements declare a variable and a
procedurePrivate mstrCustomerName As
StringPrivate Sub InitializeComponent()End Sub - Executable statements perform a specific action
- The following statement closes the form named
frmMainfrmMain.Close()
10Syntax
- 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 Strung frmMain.Closed(
)
11VB .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 boxes
- Buttons, boxes, and the form itself are all
windows - Solutions contain 1 or more forms
- Collection of forms, buttons, and boxes form the
user interface - User interface represents what the user sees and
how the user interacts with the solution
12Object Oriented Terms (1)
- 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
13Object Oriented Terms (2)
- 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
- Boxes created from the TextBox class
14The Technical View of a VB .NET Solution (1)
- 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 - Methods represent the actions an object can
perform - 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
15The Technical View of a VB .NET Solution (2)
- Use controls to create objects appearing 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 created from their
respective class
16Sample of VB .NET Controls
Label control instance to display file name
Label control instance to display a descriptive
prompt
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
17Starting VB .NET
Microsoft Visual Studio.NET 7.0
Start button
18Configuring VB .NET (1)
- 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
- Not used in this book
19Configuring VB .NET (2)
- 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
20VB .NET Options Dialog Box General Tab
Select folder
Active page highlighted
21VB .NET Options Dialog Box Projects and
Solutions Tab
Default project location
22VB .NET Window Types
Document window
Docked window
Autohidden window
Floating window
23Configuring 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 though
24Docked and Floating Toolbars
Docked toolbar
Floating toolbar
Toolbars docked along bottom of MDE
25Document 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
26Tool 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
27Document Windows and Tool Windows
Document windows appear on tab group
Close active document window
Solution Explorer is a tool window (appearing as
a docked window
28Configuring Tool Windows (1)
- 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
29Configuring Tool Windows (2)
Docked window
Autohidden windows appear along an edge of the MDE
30Getting 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
31Help Index
Index tab
Filter applied
Applicable topics
32Help Contents
Book expanded
Topic
33Help Search
Search text
Search results
34Help Dynamic Help
Dynamic Help Window
35Opening a VB .NET Solution
- Click File, and then click Open Solution
Select folder
Enter solution name
Click to Open solution
36Organization 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
37Form 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
38Elements of a Solution
solution file
form module frmDialog.vb
form module frmMain.vb
class module clsDemo.vb
project fileComplete01.vbproj
standard module stdDemo.vb
Bin folder contains compiled solution
Obj folder contains temporary files
text file
solution items
icon files
miscellaneous files
39The Solution Explorer
- Groups projects and modules comprising a
solution
40Properties Window (1)
- 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
41Properties Window (2)
Object list box
Toolbar area
Selected Font property has subproperties
Description area
42Toolbox
Visual controls appear in the Toolbox
43Operating 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
44Running 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