Introduction to computers & Visual Basic School of Business Eastern Illinois University © Abdou...

Preview:

Citation preview

Introduction to computers & Visual Basic

School of BusinessEastern Illinois University

© Abdou Illia, Spring 2003

(Week 3, Monday 1/27/2003)

2Learning Objectives

Overview of some computer-related things you should know

Introduction to Visual Basic

3Windows vs. windows

Windows desktop

4Windows vs. windows

Menu bar

Toolbar

Title bar

Work area

Scroll bar

Scroll box

Minimize button

Maximize button

Close button

Scroll box

Scroll bar

5What you should know

1. Which of the following is NOT a main component of a personal computer?(A) Microprocessor(B) Diskette drive(C) Keyboard(D) Modem(E) Monitor

2. The data used by a program do not normally come from the(A) diskette.(B) user.(C) screen.(D) program.

6What you should know

3. Which one of the following is a toggle key?(A) Alt(B) Ctrl(C) Num Lock(D) Shift(E) None of the above

4. Which key is used to move within a dialog box?(A) Space key(B) Tab key(C) Esc key(D) A cursor key

7What you should know

5. What is wrong with the file specification “C:/SPORTS/TENNIS.DOC”?

6. What is the difference between a folder and a directory?

7. In Windows 95 and 98, a file name can be no longer than(A) 25 characters.(B) 8 characters plus 3 characters for the file extension.(C) 255 characters.(D) 2550 characters.

8. Explain why “FOUR STAR HOTEL ****” is not a valid file name.

8What you should know

9. Suppose the specification of a file is “A:\ANIMAL\BIRDS\ROBIN.DOC”. How many folders must you opened in My Computer to reach the file ?

10. Distinguish between System Software and Application Software.

http://www.totalsem.com/files/Essential_Windows.pdf

Get more at:

9Visual Basic ?

BASIC stands for Beginner’s All-purpose Symbolic Instruction Code.

Visual Basic (for Windows) was developed in 1991 by the Microsoft Corporation.

Used to create Windows applications

Provides Graphical User Interface

Event-driven programming language

10Event-driven

Code remain idle until called upon to respond to events

“Nothing” happens until an event is detected

VB governed by an Event processor

Event? Event processor

BasicCode

BasicCode

BasicCode

Event Procedures

11Example of Visual Basic application

Private Sub cmdValid_Click()Dim Response As IntegerIf txtPassword.Text = txtPassword.Tag Then MsgBox "You've passed security!", vbOKOnlyElse Response = MsgBox("Incorrect password", vbRetryCancel + vbCritical, "Access Denied")End IftxtPassword.SetFocusEnd Sub

12Structure of a VB application

Control 1

Control 3

Control 2

Form 3 (.FRM) Module 1 (.BAS)

Control 1

Control 3

Control 2

Form 2 (.FRM)

Control 1

Control 3

Control 2

Form 1 (.FRM)

Project (.VBP)

13VB application (project)

Forms - Windows that you create for user interface

Controls - Graphical features drawn on forms to allow user interaction (text boxes, labels, scroll bars, command buttons, etc.) (Forms and Controls are objects.)

Properties - Every characteristic of a form or control is specified by a property. Example properties include names, captions, size, color, position, and contents. Visual Basic applies default properties. You can change properties at design time or run time.

Methods - Built-in procedure that can be invoked to impart some action to a particular object.

Event Procedures - Code related to some object. This is the code that is executed when a certain event occurs.

General Procedures - Code not related to objects. This code must be invoked by the application.

Events – Actions initiated by the user or the computer itself. In case of an event, the VB Event Processor activate the appropriate Event procedure.

14Steps to Developing VB application

1. Draw the user interface by placing controls on the form(s)

2. Assign properties to controls

3. Attach code to control events (and perhaps write other procedures)

15Steps to Developing VB application

Initial Visual Basic Screen

Main window

Form window

Toolbox

Project window

Properties window

Form Layout window

16Drawing the User Interface

VB operates in 3 modes:– Design mode– Run mode– Break mode

User Interface drawn in Design mode using :– Form window (Where you draw your application)– Toolbox (Where you select controls)– Properties window (Used to establish initial property

values for objects (controls)– Main window (for many usual operations)

17Drawing the User Interface

The Form window is central to developing application

Pointer

Label

Frame

Check Box

Combo Box

Horizontal Scroll Bar

Timer

Directory List Box

Shapes

Image Box

Object Linking Embedding

Picture Box

Text Box

Command Button

Option Button

List Box

Vertical Scroll Bar

Drive List Box

File List Box

Lines

Data Tool

The Toolbox

18Drawing the User Interface

The Properties Window

Two views are available: Alphabetic and Categorized.

Under this box are the available properties for the currently selected object.

Help with any property can be obtained by highlighting the property of interest and pressing <F1>.

The drop-down box at the top of this window lists all objects in the current form.

19Drawing the User Interface

Main Visual Basic window

New form

Add project

Open project

Save project

Menu editor

Properties window

Code Editor Tasks

Form Layout

Run

Pause

Stop

ProjectExplorer

Object Browser

Toolbox

Form position

Form dimensions

20Summary Questions

1. Explain why VB is an event-driven programming language ?

2. Name the steps to develop a VB application

3. (a) Name VB modes of operation. (b) In which mode User interfaces are drawn ?

Recommended