+ All Categories
Home > Documents > Visual Basic is an object-oriented language used to write application programs that run in Windows...

Visual Basic is an object-oriented language used to write application programs that run in Windows...

Date post: 23-Dec-2015
Category:
Upload: sybil-clarke
View: 225 times
Download: 2 times
Share this document with a friend
Popular Tags:
27
Visual Basic is an object-oriented language used to write application programs that run in Windows or on the Internet using a graphical user interface (GUI). The three steps to creating a Visual Basic project are (1) define the user interface, (2) set the properties, and (3) write the Basic code. 1- 1 The Graphical User Interface
Transcript

Visual Basic is an object-oriented language used to write application programs that run in Windows or on the Internet using a graphical user interface (GUI).

The three steps to creating a Visual Basic project are (1) define the user interface, (2) set the properties, and (3) write the Basic code.

1- 1

The Graphical User Interface

Design/Define the User Interface Plan/Set the Properties Plan/Write the Code Test and Debug

1- 2

Steps for Writing VB Projects

Windows Graphical User Interface Window = Form Toolbox of elements called Controls

◦ Text Box◦ Label◦ Check Box◦ Button

1- 3

Writing Windows Applications with VB

Procedural◦ Program specifies exact sequence

Event Driven (VB 6.0 and previous) Object Oriented Programming (VB.NET)

◦ User controls sequence Click event Double Click event Change event

1- 4

Programming Languages

Object ==> Noun◦ Form and Controls

Property ==> Adjective◦ Color of a Form

Method ==> Verb◦ Move a Form

Event ==> Occur when the user takes action◦ User clicks a button, User moves a form

Class ==> Template to create new object◦ Each control added is an Instance of a Class

1- 5

Object Model

Used to reference object's properties and methods in code◦ Object dot Property

Form.Text, TextBox.Text◦ Object dot Method

Form.Hide( ), TextBox.Focus( ) To reference an object's events use an

underscore instead of a dot Button_Click, ListBox_TextChanged

1- 6

Dot Notation

Class = automobile Properties = make, model, color, year Object = each individual car

◦ Object is also an Instance of the automobile class Methods = start, stop, speedup, slowdown Events = car arrives, car crashes

1- 7

Object Model Analogy

One Solution File .sln Solution User Options File .suo Project Files .vbproj Project User Options File

.vbproj.user Form Files .vb Resource File for the Form .resx

1- 8

VB Application Files

Open this file directly to work on a Project

Integrated Development Environment (IDE) Form Designer Editor for entering code Compiler Debugger Object Browser

1- 9

Visual Studio Environment

Toolbars Document Window Form Designer Solution Explorer Properties Window Toolbox

1- 10

IDE Main Window

1- 11

OLDER IDE Main Window

1- 12

Current IDE

Holds the tools you place on a form

1- 13

VB Toolbox

Design Time Run Time Break Time

1- 14

Modes

“Look at the Title Bar”

Always use standard names for objects No spaces or punctuation marks 3 letter lowercase prefix identifies control

type Button-btn Label-lbl Form-frm

If multiple words capitalize 1st letter of each word

1- 15

Naming Rules (p 43-44)

1- 16

Recommended Naming Conventions for VB Objects

Object Class Prefix ExampleForm frm frmDataEntryButton btn btnExitTextBox txt txtPaymentAmountLabel lbl lblTotalRadio Button rad radBoldCheckBox chk chkPrintSummaryHorizontal ScrollBar hsb hsbRateVertical ScrollBar vsb vsbTemperaturePictureBox pic picLandscapeComboBox cbo cboBookListListBox lst lstIndegredients

1- 17

Hello World Project Design the User Interface

lblMessage

btnPush

btnExit

1- 18

Properties Window-Label1

Rename Label1 to lblMessage

Label◦ Name lblMessage◦ Text leave blank

Button 1◦ Name btnPush◦ Text Push Me

Button 2◦ Name btnExit◦ Text Exit

Form◦ Name frmHello◦ Text Hello World by your name

1- 19

Set the Properties

The default startup object if Form1 The name of the form should always be

changed to adhere to naming rules Using Project menu, Properties change the

startup object to match the new name

1- 20

Set the Project's Startup Object

1- 21

Project Property Page Dialog

While the project is running the user can perform actions

Each action by the user causes an Event to occur

Write code for the events you care about, the events you want to respond with code

Code is written as event procedures VB will ignore events for which you do

not write code

1- 22

Write the Code

Declarations Section Class list Method list

1- 23

Editor Window

Also known as Comment, used for documentation

Non-executable Automatically colored Green in Editor Begins with an apostrophe ( ' )

◦ On a separate line from executable code◦ At the right end of a line of executable code

1- 24

Remark Statement

' Display the Hello World message

Assigns a value to a property or variable Operates from right to left Enclose text strings in quotation marks ("

")

1- 25

Assignment Statement

lblMessage.Text=" Hello World "

Execute the Close Method of the Form Methods always have parentheses (this

will help you distinguish them from Properties which never have parentheses)

Current Form may be referenced as Me

1- 26

Ending a Program

Me.Close( )

Save Project - File Menu, Save All Run Project

◦ Debug Menu, Start◦ Start Without Full Compile (F5) ◦ Start With Full Compile (CTRL F5)

Correct any Errors and Rerun◦ Compile errors◦ Run-Time Errors◦ Logic errors◦ Syntax errors

1- 27

Test and Debug

"Help is always available from the Help Menu or by pressing F1."


Recommended