slide 1 ics 012 visual programming i ahmed esmat [email protected] second

22
Slide 1 http:// ICS 012 Visual Programming I Ahmed Esmat [email protected] http://staff.kfupm.edu.sa/ITC/aesmat / Second Semester 2004-2005 (042)

Post on 21-Dec-2015

221 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 1http://staff.kfupm.edu.sa/ITC/aesmat/

ICS 012 Visual Programming I

Ahmed Esmat

[email protected]

http://staff.kfupm.edu.sa/ITC/aesmat/

Second Semester 2004-2005 (042)

Page 2: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 2http://staff.kfupm.edu.sa/ITC/aesmat/

ICS 012 Visual Programming I

WEEK 1

Visual and Event Driven Programming

An Overview of Visual Basic (IDE)

Page 3: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 3http://staff.kfupm.edu.sa/ITC/aesmat/

Aims and Objectives

To understand what is visual and event driven programming

The Visual Basic Programming environment– Background to BASIC

– Background to Windows

– Visual Basic Environment

– Design/Control/Project/Form/Code Windows

– Control Properties

– Events & Event Driven Programming

– Visual Basic Programs

Page 4: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 4http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Programming

Aims

Aim is to develop the necessary skills to design and construct small-scale interactive software

Aim is to educate you with the fundamental principles of designing and writing programs

Visual Basic will be the target language but skills gained will be applicable to other languages

Page 5: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 5http://staff.kfupm.edu.sa/ITC/aesmat/

Event Driven Programming

Event-driven programs respond to events from the computer, such as the mouse button being pressed.

The designer uses ready-made objects such as CommandButtons and TextBoxes, to build user interfaces that make up the application.

This approach to programming drastically reduces the amount of code required to develop a Windows application.

Page 6: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 6http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Programming Languages

Windows easy to use Programming via Visual environments

– .NET

– Visual C++, C#

– Java, J++, J#

– Borland Delphi and others…

Visual Basic developed in-house at Microsoft– Interface designer

– Simple coding language

– Quick to produce programs

Page 7: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 7http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Concepts

Controls - Processing– Everything is a ‘control’

– Controls have pre-defined ‘events’

– Code can be attached to an event

– When an event occurs if code has been attached it is executed, otherwise default processing takes place

Page 8: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 8http://staff.kfupm.edu.sa/ITC/aesmat/

Running VB

Opening screen

Select this option -

Standard EXE

Page 9: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 9http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Environment

Components of the VB Design Environment

FormProject Explorer

Properties

Form Layout

ControlToolbox

Toolbar

Page 10: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 10http://staff.kfupm.edu.sa/ITC/aesmat/

Event Driven Programs in VB

In normal programming your application is always in control

In GUI(Graphical User Interface) programming you have a number of options which may be triggered

Events happen to a Control– mostly user generated events

– controls can also cause events

Page 11: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 11http://staff.kfupm.edu.sa/ITC/aesmat/

Control Toolbox

Page 12: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 12http://staff.kfupm.edu.sa/ITC/aesmat/

Events

Each Control has a relevant set of Events

The events that can happen to a Command Button

Page 13: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 13http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Environment- Properties Window

Controls - Properties– All controls have appropriate

properties such as Height, Name, Colour

– they can be changed either at design-time or at run-time

Main Menu

Design Time– Simply change the words

alongside the property. Ie

Page 14: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 14http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Environment- Properties Window

Run Time– in your code/program

Private Sub Form1_load()Form1.Caption = “Main Menu”

End Sub

Page 15: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 15http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Event Processing

Trigger Event

Code Executed

Page 16: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 16http://staff.kfupm.edu.sa/ITC/aesmat/

Project Explorer

Page 17: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 17http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Program Structure

Project File– ‘.VBP’

Form Files– ‘.FRM’

– ‘.FRX’

Modules– ‘.BAS’

Custom Controls– ‘.VBX’ files

Save As...– Possible

problem

Page 18: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 18http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Basic Environment- Using Context Sensitive Help

Context sensitive help is very useful Select the item control that you want help on Press the F1 key

F1

Page 19: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 19http://staff.kfupm.edu.sa/ITC/aesmat/

Command Button

Select the command button

from the toolbar

Page 20: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 20http://staff.kfupm.edu.sa/ITC/aesmat/

Controls: Shape

A shape control allows you to‘draw’ on the screen

You can specify the:ShapeColours FillStyle

Page 21: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 21http://staff.kfupm.edu.sa/ITC/aesmat/

Visual Separation of Controls

Page 22: Slide 1  ICS 012 Visual Programming I Ahmed Esmat aesmat@kfupm.edu.sa  Second

Slide 22http://staff.kfupm.edu.sa/ITC/aesmat/

Writing VB Programs

Plan the Program Tasks Design User Interface Set Properties Write Code (Event Handlers) Test and Debug the Program Document and Distribute the Program