CHE110-L09 - Chemical Engineering Sub Procedure Arguments...

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

View Full Document Right Arrow Icon
Department of Chemical Engineering Sub Procedures CHE110 Introduction to Programming & Problem Solving
Background image of page 1

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

View Full DocumentRight Arrow Icon
Department of Chemical Engineering Sub Procedure Syntax Naming Sub Procedures – follows variable naming rules Declaring Sub Procedures Sub ProcedureName (arguments) [lines of code] End Sub Scope of a Sub Procedure – All Sub procedures are Public by default - can be called by any procedure in any module –U s e Private keyword to restrict to module-wide scope Private Sub ProcedureName (arguments)
Background image of page 2
Department of Chemical Engineering Calling A Sub Procedure Using the Call keyword Sub CallingSub() Call ProcedureName (arg1, arg2, …) End Sub Sub ProcedureName (arg1 As Double, arg2 As Long, …) [lines of code] End Sub Alternative – No Call Keyword or Parentheses Sub CallingSub() ProcedureName arg1, arg2, … End Sub Sub ProcedureName (arg1 As Double, arg2 As Long, …) [lines of code] End Sub Argument Data Types are specified in the Sub declaration line.
Background image of page 3

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

View Full DocumentRight Arrow Icon
Department of
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chemical Engineering Sub Procedure Arguments Passing By Reference or By Value • Passing By Reference – memory address of variable passed – can modify variable contents – default method • Passing By Value – copy of variable contents passed (requires more memory) – cannot modify variable contents – use ByVal keyword in Sub definition line Sub ProcedureName ( ByVal arg1 As Double ) Department of Chemical Engineering Sub Procedure Arguments Optional Arguments • Optional arguments are specified using the Optional keyword Call ProcedureName (arg1,arg2) or Call ProcedureName (arg1) or Call ProcedureName (, arg2) Sub ProcedureName ( Optional arg1 As Double , Optional arg2 As Long ) • Default Value for an omitted Optional argument can be specified Call ProcedureName (arg1) Sub ProcedureName ( Optional arg1 As Double , Optional arg2 As Long = 100)...
View Full Document

This note was uploaded on 03/08/2009 for the course CHE 101 taught by Professor Coronel during the Spring '06 term at Rose-Hulman.

Page1 / 5

CHE110-L09 - Chemical Engineering Sub Procedure Arguments...

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

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