Chapter 41 General Procedures Sub Procedures, Part I Sub Procedures, Part II Function Procedures.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 6- 1 STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Advertisements

Chapter 6, Slide 1Starting Out with Visual Basic 3 rd Edition Chapter 6 Sub Procedures And Functions.
Sub and Function Procedures
Murach, Chapter 6. Murach’s Visual Basic 2008, C6© 2008, Mike Murach & Associates, Inc. Slide 2.
1 5.3 Sub Procedures, Part II Passing by Value Passing by Reference Sub Procedures that Return a Single Value Debugging.
1.
1 Chapter 5 - General Procedures 5.1 Function Procedures 5.2 Sub Procedures, Part I 5.3 Sub Procedures, Part II 5.4 Modular Design.
1 CS 106, Winter 2009 Class 10, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
1 CS 106, Winter 2009 Class 11, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
Passing Arguments Question Example: IS1102 Exam Autumn 2001.
Chapter 4 General Procedures
Chapter 4 (cont) Sec. 4.1, 4.2, 4.4 Procedures (User-defined)
Chapter 4 - VB.Net by Schneider1 Chapter 4 General Procedures 4.1 Sub Procedures, Part I 4.2 Sub Procedures, Part II 4.3 Function Procedures 4.4 Modular.
Chapter 41 Sub Procedures, Part II Passing by Value Passing by Reference Local Variables Class-Level Variables Debugging.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
Chapter 41 Function Procedures (Continue I). Chapter 42 Lab Sheet 4.7: Code Private Sub btnCalculate_Click(...) _ Handles btnCalculate.Click Dim a, b.
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Chapter 4 Sec. 4.1, 4.2, 4.4 Procedures (User-defined)
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Subroutines and Functions Chapter 6. Introduction So far, most of the code has been inside a single method for an event –Fine for small programs, but.
Chapter 5 - VB 2008 by Schneider1 Chapter 5 - General Procedures 5.1 Sub Procedures, Part I 5.2 Sub Procedures, Part II 5.3 Function Procedures 5.4 Modular.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
1 Chapter 5 - General Procedures 5.1 Function Procedures 5.2 Sub Procedures, Part I 5.3 Sub Procedures, Part II 5.4 Modular Design.
T ODAY ’ S Q UOTE “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are–by.
CSCI 3327 Visual Basic Chapter 6: Methods: A Deeper Look UTPA – Fall 2011.
1 Chapter 5 - General Procedures 5.1 Function Procedures 5.2 Sub Procedures, Part I 5.3 Sub Procedures, Part II 5.4 Modular Design.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 7 Sub and Function Procedures.
Subroutines and Functions. Introduction So far, most of the code has been inside a single method for an event –Fine for small programs, but inconvenient.
Subprograms CE 311 K - Introduction to Computer Methods Daene C. McKinney.
110-G1 Motivation: Within a program, may have to perform the same computation over and over Many programs share the same computation (e.g. sorting) To.
Chapter 6 Sub Procedures
Chapter 9: Writing Procedures Visual Basic.NET Programming: From Problem Analysis to Program Design.
Programming with Visual C++: Concepts and Projects Chapter 2B: Reading, Processing and Displaying Data (Tutorial)
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Sub Procedures. A Sub procedure is a block of code that is executed in response to an event. There are two types of Sub procedures, general procedures.
© 2006 ITT Educational Services Inc. Introduction to Computer Programming: Unit 10: Chapter 6: Slide 1 Unit 10 Sub Procedures and Functions Chapter 6 Sub.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Functions Chapter 6. Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules Function: a collection.
1Edited By Maysoon Al-Duwais. 2 General Procedures Function Procedure Sub Procedures, Part I Sub Procedures, Part II Modular Design Edited By Maysoon.
Week Procedures And Functions 7 A procedure is a collection of statements that performs a task.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
Sub Procedures; Passing Values Back From Sub Procedures Passing by reference Passing by value.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
General Procedures Chapter 4. Different Procedures 4.1 Sub Procedures, Part I 4.2 Sub Procedures, Part II 4.3 Function Procedures 4.4 Modular Design (not.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 6 Sub Procedures And Functions.
Copyright © 2014 Pearson Education, Inc. Chapter 6 Procedures and Functions.
Subroutines and Functions Chapter 6. Introduction So far, all of the code you have written has been inside a single procedure. –Fine for small programs,
1Edited By Maysoon Al-Duwais. 2 Devices for Modularity Visual Basic has two ways for breaking problems into smaller pieces: Sub procedures Function procedures.
Sub Procedures and Functions Visual Basic. Sub Procedures Slide 2 of 26 Topic & Structure of the lesson Introduction to Modular Design Concepts Write.
1Lect7 GC20111/2/ General Procedures Function Procedure Sub Procedures, Part I Sub Procedures, Part II Modular Design Lect7 GC20111/2/2015.
CS0004: Introduction to Programming
Sub Procedures And Functions
Functions Chapter 6-Part 2.
Method.
Chapter#8 General Procedures
Chapter 4 - Visual Basic Schneider
5.2 Sub Procedures, Part I Defining and Calling Sub Procedures
Procedures and Functions
Chapter#8 General Procedures
Chapter 5 - General Procedures
Chapter 9: Value-Returning Functions
Chapter 5 - General Procedures
Fundamental Programming
STARTING OUT WITH Visual Basic 2008
Chapter 4 General Procedures
Chapter (3) - Procedures
Introducing Modularity
Presentation transcript:

Chapter 41 General Procedures Sub Procedures, Part I Sub Procedures, Part II Function Procedures

Chapter 42 Sub Procedures, Part I Sub Procedures Variables and Expressions as Arguments Calling Other Sub Procedures

Chapter 43 Devices for modularity Visual Basic has two devices for breaking problems into smaller pieces: Sub procedures Function procedures

Chapter 44 Sub Procedures Perform one or more related tasks General syntax Sub ProcedureName() statements End Sub

Chapter 45 Calling a Sub procedure The statement that invokes a Sub procedure is also referred to as a call statement. A call statement looks like this: ProcedureName()

Chapter 46 Naming Sub procedures The rules for naming Sub procedures are the same as the rules for naming variables.

Chapter 47 Sub ExplainPurpose() Lab sheet 4.2: Code lstBox.Items.Clear() ExplainPurpose() lstBox.Items.Add("") lstBox.Items.Add("Program displays a sentence") lstBox.Items.Add("identifying a sum.") End Sub

Chapter 48 Passing Values You can send values to a Sub procedure Sum(2, 3) Sub Sum(ByVal num1 As Double, ByVal num2 As Double) lstBox.Items.Add("The sum of " & num1 & " and " _ & num2 & " is " & (num1 + num2) & "." End Sub In the Sum Sub procedure, 2 will be stored in num1 and 3 will be stored in num2

Chapter 49 Arguments and Parameters Sum(2, 3) Sub Sum(ByVal num1 As Double, ByVal num2 As Double) arguments parameters displayed automatically

Chapter 410 Several Calling Statements ExplainPurpose() Sum(2, 3) Sum(4, 6) Sum(7, 8) Output: Program displays a sentence identifying a sum. The sum of 2 and 3 is 5. The sum of 4 and 6 is 10 The sum of 7 and 8 is 15.