Getting Started with VB 'NET - PowerPoint PPT Presentation

1 / 44
About This Presentation
Title:

Getting Started with VB 'NET

Description:

Programming with Visual Basic .NET. An Object Oriented ... Learn about VB .NET and the characteristics of a VB .NET solution. Start and ... sub folder ... – PowerPoint PPT presentation

Number of Views:269
Avg rating:3.0/5.0
Slides: 45
Provided by: michaelv50
Category:

less

Transcript and Presenter's Notes

Title: Getting Started with VB 'NET


1
Chapter 1
  • Getting Started with VB .NET

2
Objectives
  • 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

3
Introducing 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

4
Introducing 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

5
Differences 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

6
Facts 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.

7
Facts 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

8
Program 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
9
Types 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()

10
Syntax
  • 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(
)
11
VB .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

12
Object 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

13
Object 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

14
The 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

15
The 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

16
Sample 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
17
Starting VB .NET
Microsoft Visual Studio.NET 7.0
Start button
18
Configuring 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

19
Configuring 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

20
VB .NET Options Dialog Box General Tab
Select folder
Active page highlighted
21
VB .NET Options Dialog Box Projects and
Solutions Tab
Default project location
22
VB .NET Window Types
Document window
Docked window
Autohidden window
Floating window
23
Configuring 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

24
Docked and Floating Toolbars
Docked toolbar
Floating toolbar
Toolbars docked along bottom of MDE
25
Document 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

26
Tool 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

27
Document 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
28
Configuring 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

29
Configuring Tool Windows (2)
Docked window
Autohidden windows appear along an edge of the MDE
30
Getting 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

31
Help Index
Index tab
Filter applied
Applicable topics
32
Help Contents
Book expanded
Topic
33
Help Search
Search text
Search results
34
Help Dynamic Help
Dynamic Help Window
35
Opening a VB .NET Solution
  • Click File, and then click Open Solution

Select folder
Enter solution name
Click to Open solution
36
Organization 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

37
Form 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

38
Elements 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
39
The Solution Explorer
  • Groups projects and modules comprising a
    solution

40
Properties 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

41
Properties Window (2)
Object list box
Toolbar area
Selected Font property has subproperties
Description area
42
Toolbox
Visual controls appear in the Toolbox
43
Operating 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

44
Running 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
Write a Comment
User Comments (0)
About PowerShow.com