Slieds - Chapter 6

Slieds - Chapter 6 - Chapter6 SubandFunctionProcedures 1...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 6 Sub and Function Procedures BMGT 302 Business Application  Programming 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Procedures  Procedure : a block of program code that performs a  specific task Two types of procedures: Function procedure : returns a value after performing its  task Sub procedure : does not return a value In Object-oriented programming, the term  method  is  used to mean both sub and function procedures 2
Background image of page 2
Sub Procedures Two types of Sub procedures Event procedure Sub procedure that is associated with a specific object and event Automatically processed when the associated event occurs Independent Sub procedure Collection of code that can be invoked from one or more places in  an application Not associated with an event Processed only when called (invoked) 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sub Procedures (cont'd.) Independent Sub procedures are used to: Eliminate the duplication of code in different parts of a  program Allow a large, complex application to be broken into small  and manageable tasks Allow multiple programmers to work on an application  simultaneously 4
Background image of page 4
How to create an independent Sub procedure 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sub Procedures (cont'd.) Independent Sub procedures: Have a procedure header and procedure footer Use  Pascal case  for names Optionally contain a parameter list Parameters Declared in the procedure header Store the information passed into the procedure when it is  invoked Call  statement : invokes an independent Sub  procedure 6
Background image of page 6
Sub Procedures (cont'd.) How to call an independent Sub procedure 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The Gadis Antiques Application Sample run of the Gadis Antiques application 8
Background image of page 8
Partial code for the  Gadis Antiques  application 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
In-class exercise Tutorial 6-1: Lights 10
Background image of page 10
Including Parameters in an Independent  Sub Procedure Parameter : stores data that is passed to the  procedure when the procedure is invoked When calling a procedure with parameters, you 
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 42

Slieds - Chapter 6 - Chapter6 SubandFunctionProcedures 1...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online