Upload
drago-devcic
View
223
Download
0
Embed Size (px)
Citation preview
8/4/2019 2-4 Visual Basic 2008-Intro
1/22
26Lecture SectionC
Addawe
1
VISUAL BASIC 2008Chapter 2-4
Creating a Project2
8/4/2019 2-4 Visual Basic 2008-Intro
2/22
26Lecture SectionC
Addawe
Projects Templates (for VB Express)
Windows Forms
3
Lets you easily design
familiar windows style
applications
Used to create
Windows-based
applications that run
locally on users'
computers.
Projects Templates (for VB Express)
Class Library
4
Used to create
reusable classes or
components that can
be shared with
multiple projects. Provides a class
module where custom
objects can be created
8/4/2019 2-4 Visual Basic 2008-Intro
3/22
26Lecture SectionC
Addawe
Projects Templates (for VB Express)
WPF Application
5
Used to create stand-alone WindowsPresentationFoundation (WPF)applications.
applications with a richGraphical User
Interface
Projects Templates (for VB Express)
WPF Browser
6
Used to create
browser-hosted
Windows Presentation
Foundation
applications.
8/4/2019 2-4 Visual Basic 2008-Intro
4/22
26Lecture SectionC
Addawe
Projects Templates (for VB Express)
Console Application
7
Used to create
command-line
applications, programs
that run from a
Windows command
prompt and have no
visual interface.
Visual Studio IDE8
8/4/2019 2-4 Visual Basic 2008-Intro
5/22
26Lecture SectionC
Addawe
Projects and Solutions
In Visual Studio, programs under development aret icall called ro ects orsolutions
9
Because they contain many individual components (not justone file)
VB 2008 programs include:
a project file (.vbproj) and;
Contains information specific to a single programming task
.
Are useful to manage multiple related projects
Note: For a solution having a single project, opening the project file
is the same as opening the solution file. But for a multi-projectsolution, the solution file must be opened.
Visual Studio IDE
Microsoft Visual Studio Integrated Development
10
Menus, tools, component windows (tool windows)
Menu bar
Standard toolbar
Designer (Form Window)
Solution Ex lorer Properties window
Toolbox
*Code editor window
8/4/2019 2-4 Visual Basic 2008-Intro
6/22
26Lecture SectionC
Addawe
Visual Studio IDE11
Menu bar - provides access to most of the
commands that control the development environment
serve as shortcuts for executing commands and
controlling the Visual Studio IDE
Visual Studio IDE
Designer
12
user nter ace or orm;
acts as a container for Controls to
be used in the application.
8/4/2019 2-4 Visual Basic 2008-Intro
7/22
26Lecture SectionC
Addawe
Visual Studio IDE
Solution Explorer
Properties
View Code
13
n area o t e t at
contains your solution
Helps you manage
your project files.
The files are displayed
ow a i es
Refresh
View Designer
,
much like that of
Windows Explorer
Visual Studio IDE
Properties Window
14
se to c ange t e c aracter st cs,
or property settings, of the UI
elements o a form
A property setting is a qualityof
one of the objects in your program
Design time (Properties window)
Run time (Code Editor)
8/4/2019 2-4 Visual Basic 2008-Intro
8/22
26Lecture SectionC
Addawe
The Visual Studio Tools15
Object list- itemizes all the UI
elements (objects) on the form
Property settings
Properties list
Events button
Alphabetical button
Categorized button
Properties button
Visual Studio IDE
Toolbox
16
a conta ner or a t e
controls
8/4/2019 2-4 Visual Basic 2008-Intro
9/22
26Lecture SectionC
Addawe
Tab Name Description
All Windows
Form
Contains all the standard Windows Forms controls that are available in the
Toolbox.Common
Controls
Contains the most common controls that are typically used in Windows-based
applications.
Toolbox Tabs
Containers Contains controls that hold other controls, such as GroupBox controls and Panel
controls. Containers can help isolate a set of controls from other controls on the
form.
Menus and
ToolBars
Contains controls that enable you to create menus and toolbars for your
application, such as the MenuStrip and ToolStrip controls.
Data Contains controls that help you easily work with data in your application, such
as the DataGridView control.
Components Contains components that typically do not have a user interface, such as the
Timer and the ErrorProvider.
Printing Contains controls that enable you to provide printing capabilities to anapplication.
Dialogs Contains controls that let you use common dialog boxes in your application,
such as the SaveFileDialog, FolderBrowserDialog and FontDialog controls.17
IDE Features18
8/4/2019 2-4 Visual Basic 2008-Intro
10/22
26Lecture SectionC
Addawe
Auto hide pushpin
IDE Features19
Docking guides20
8/4/2019 2-4 Visual Basic 2008-Intro
11/22
26Lecture SectionC
Addawe
IDE Navigator-a feature that allows the user to cycle through open files and tools
by using key combinations (Ctrl+Tab; Ctrl+Shift+Tab reverse direction)
Press Alt+F7 or Shift+Alt+F7 to cycle through open tools without opening the IDE
Navigator
Switching among files and tools using the IDE Navigator21
Creatin the User Interface22
8/4/2019 2-4 Visual Basic 2008-Intro
12/22
26Lecture SectionC
Addawe
Terminology (OOP)
Control
23
,
objects are created on a form; controls are selected from the
toolbox and then drawn on the form
Different ways of adding controls to the Form:
By double-clicking (default size)
Drag and drop (default size)
Click and drag
Terminology (OOP)
Object
24
Toolbox
Technically speaking objects are instances of a class that
supports properties, methods and events
Has inherent functionality - they know how to operate and can
respond to certain situations on their own (e.g. a list box knows
how to scroll)
8/4/2019 2-4 Visual Basic 2008-Intro
13/22
26Lecture SectionC
Addawe
Terminology (OOP)
Class
25
the object does (but is not the object itself)
In Visual Basic, you can use existing Visual Studio classes (like
System.Math and System.Windows.Forms.Form) and you can build
your own classes and inherentproperties, methods and events
from them
Note:Inheritance allows one class to acquire the pre-existing interface
and behavior characteristics of another class
Terminology (OOP)
Namespace
26
(e.g. System.Windows and System.Diagnostics)
Note: To access the classes and underlying objects within a
namespace, place an Imports statement at the top of your
program code
8/4/2019 2-4 Visual Basic 2008-Intro
14/22
26Lecture SectionC
Addawe
Terminology (OOP)
Property
27
Setting a property:
Design time using the Properties window
Run time using statements in the program code
Object.Property =Valuee.g. Label1.Text =Hello!
Me.BackColor=Color.Yellow
Event procedure
A block of code that is executed when an object is manipulated in
a program
Terminology (OOP)
Method
28
particular object in a program
Notation:Object.Method(Value)
e.g. Textbox1.Clear()
Me.Hide()
Listbox1.Items.Add(Check)
8/4/2019 2-4 Visual Basic 2008-Intro
15/22
26Lecture SectionC
Addawe
Interface Styles
Single-Document Interface (SDI)
29
n y one ocument at a time is opene
Multiple-Document Interface (MDI)
Multiple forms within a single container form
Explorer-Style Interface
a single window containing two panes or regions,
usually consisting of a tree or hierarchical view on the
left and a display area on the right
Interface Styles
Single-Document Interface (SDI)
30
8/4/2019 2-4 Visual Basic 2008-Intro
16/22
26Lecture SectionC
Addawe
Interface Styles31
Multiple-Document Interface (MDI)
Interface Styles32
Explorer-Style Interface
8/4/2019 2-4 Visual Basic 2008-Intro
17/22
26Lecture SectionC
Addawe
Interface Desi n33
Positioning of objects
More important elements must be readily apparent to
34
Most user's eyes will be drawn to the upper left
portion of the screen first.
Organize the user interface so that the information flows
either vertically or horizontally, with most important
information always located in the upper-left corner of the
screen
8/4/2019 2-4 Visual Basic 2008-Intro
18/22
26Lecture SectionC
Addawe
Positioning of objects
Grouping of elements and controls is also important.
35
,
GroupBox, or Panel
The use of white space can help emphasize elements and
improve usability
Under Containers category in the Toolbox
Consistency of interface elements
Inconsistency makes your application confusing, chaotic,
36
Establish a design strategy and style conventions
before you begin development
Keep it simple
8/4/2019 2-4 Visual Basic 2008-Intro
19/22
26Lecture SectionC
Addawe
Tooltip control
Tooltip an object used to provide visual clues to
37
u
Tips on GUI design
Images and Icons
38
interest to your application, but again, careful design isessential
Choosing Fonts
select fonts that will be easily readable at differentresolutions and on different types of displays
8/4/2019 2-4 Visual Basic 2008-Intro
20/22
26Lecture SectionC
Addawe
Tips on GUI design
Use meaningful captions or text in all objects
39
Label each control in the user interface
Align the labels and controls in the userinterface
ue an p n snap nes
Naming Objects
Must begin with a letter
40
Can contain letters and numbers
Cannot contain a period
It is better to prefix a name with letters
representing the kind of object they are naming
to eliminate confusion especially when the
application contains many objects
Use meaningful names
8/4/2019 2-4 Visual Basic 2008-Intro
21/22
26Lecture SectionC
Addawe
Writin the code41
Writing the code
Code Editor Window Contains program statements associated with the form
42
Program statements that are used together to performsome action are typically grouped in a programmingconstruct called a procedure
Procedures are typically executed when certain events occur(e.g. when a button is clicked) When a procedure is associated with a particular object and event,
it is called an event handleror an event procedure.
Method NameClass Name
8/4/2019 2-4 Visual Basic 2008-Intro
22/22
26Lecture SectionC
Running a Visual Basic Program
Click the Start Debugging button
43
Press F5
Click the Start Debugging command on the Debug
menu
Building Executable Files
Creating an application for Windows (.exe)
Two types of files that can be created:
44
Debug build Stored in a folder called bin\debug within the project folder
Contains debugging information that makes the program slightlyslower
Release build Stored in a folder called bin\release within the project folder
Optimized executable files