Download presentation
Presentation is loading. Please wait.
Published byKátia Gomes Botelho Modified over 6 years ago
1
CIS16 Application Development Programming with Visual Basic
Chapter One An Introduction to Visual Basic
2
Visual Studio Visual Basic is an object-oriented programming language (OOP) Object: anything that can be seen, touched, or used Class: a pattern used to create an object Instance: an object created from a class; object is said to be instantiated Integrated Development Environment (IDE): Contains all the tools and features needed to create, run, and test programs Download a free copy at
3
Visual Studio (cont'd.) Used to create software applications
Application: program or suite of programs Windows-based application: Has a Windows user interface User interface: what the user sees and interacts with when using an application Runs on a personal computer Web-based application: Has a Web user interface Runs using a web server Accessed with a computer browser
4
Creating a Visual Basic Windows Application
Windows applications consist of solutions, projects, and files Solution: a container that stores projects and files for an entire application Project: a container that stores files associated with a specific portion of the solution A solution may contain one or more projects
5
Visual Studio IDE
6
Setting OPTIONS
7
Create a new Visual Basic Windows Application
New Project dialog box
8
A Visual Basic Windows Application
Solution and Visual Basic Project
9
The Windows Form Designer Window
Allows you to create (design) the GUI Graphical user interface (GUI): What the user sees and interacts with Windows Form object (or form): Foundation for the user interface Add other objects such as buttons/text boxes to form Title bar with caption and Minimize, Maximize, and Close buttons Tab at top of designer window has Form1.vb [Design]
10
The Solution Explorer Window
Displays a list of projects contained in this solution Displays the items contained in each project Solution Explorer window
11
The Solution Explorer Window – Types of project files(cont'd.)
Source file A file containing program instructions (code) Form file A file containing code associated with a Windows form Give each form file a meaningful name using the Properties window
12
The Properties Window Properties Properties window
A set of attributes that determine an object’s appearance and behavior Properties window Displays properties of the selected object Default property values are assigned when an object is created 20
13
Properties of a Windows Form
Class definition Block of code that defines the attributes and behaviors of an object All class definitions are contained in namespaces Namespace: Defines a group of related classes Dot member access operator The period that separates words in an object’s name to indicate a hierarchy of namespaces
14
Properties of a Windows Form (cont'd.)
Name and Text Properties Assign meaningful names to forms and use a naming convention Pascal case First letter of each word in the name is uppercase First part of name is object’s purpose Second part of name is object’s class i.e. EmployeeDataForm Text property Controls the caption displayed on form’s title bar
15
The Toolbox Window Toolbox Controls
Contains objects that can be added to other objects, such as a form Each tool has an icon and a name to identify it Each tool represents a class from which objects, called controls, can be created Controls Objects displayed on a form Represented as icons in the toolbox Controls on a form can be selected, sized, moved, deleted, locked in place on the form and unlocked
16
The Toolbox Window (cont’d.)
17
The Toolbox Window (cont’d.)
Control names use camel case Camel case: Lowercase first word; uppercase first letter of each subsequent word in the name for labels used as prompts, it is not necessary to assign meaningful names because they are never used in code Labels used for output should have meaningful names Label control: Displays text that user cannot edit Used as “prompts” to explain controls or display output Name should end with “Label” i.e. subtotalLabel
18
The Toolbox Window (cont’d.)
Button control Performs an immediate action when clicked Its name should end with “Button” Picture Box Control Displays an image on the form
19
The Code Editor Window Events: Event procedure: Code editor window:
User actions while program is running Examples: clicking, double-clicking, scrolling Event procedure: Set of instructions to be processed when an event occurs Tells the object how to respond to an event Code editor window: Used to enter event procedure’s code
20
The Code Editor Window (cont'd.)
21
The Code Editor Window (cont'd.)
Class statement Used to define a class Class Name list box Lists the names of objects (controls) included in the user interface Method Name list box Lists the events to which the selected object is capable of responding Method: Predefined VB procedure that can be invoked (called) when needed
22
The Code Editor Window (cont'd.)
Event code template has a procedure header and a procedure footer Begins with keywords Private Sub Procedure name includes object name and event name Handles clause indicates for which objects’ events this code will execute
23
The Code Editor Window (cont'd.)
Keyword A word with special meaning in a programming language Me keyword: refers to the current form Me.Close() instruction Closes the current form at run time If the current form is the only form, the application is terminated
24
The Code Editor Window (cont'd.)
Sub procedure Block of code that performs a task Sequential processing Each line is executed in sequence Also called a sequence structure Syntax rules of the programming language
25
Starting and Ending an Application
When you start a VB application, the IDE creates an executable file Executable file Can be run outside of Visual Studio Has a file extension of .exe Stored in the project’s bin\Debug folder
26
Syntax Errors Syntax error
Occurs when you break one of the programming language’s rules Most syntax errors are caused by typing errors Rest the mouse pointer on the mistyped instruction to see details about the error
27
Syntax Errors (cont’d.)
Syntax error in the exitButton’s Click procedure Result of placing the mouse pointer on the jagged blue line
28
Syntax Errors (cont’d.)
Syntax errors should be corrected before starting an application If you start an application with a syntax error, a dialog box appears Syntax error message Result of starting an application that contains a syntax error
29
Bugs Bug Debugging An error in a program’s code
The process of locating and correcting bugs in a program
30
Closing the Current Solution
Closing a solution closes all projects and files in that solution You are prompted to save any files that have unsaved changes
31
Opening an Existing Solution
Only one solution can be open at any one time If a solution is already open, opening a different one will close the currently open solution
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.