Chapter 6 Sub Procedures

Slides:



Advertisements
Similar presentations
Sub and Function Procedures
Advertisements

The Web Warrior Guide to Web Design Technologies
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Eight Sub and Function Procedures.
1.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
Chapter 4 - Visual Basic Schneider
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Python quick start guide
Apply Sub Procedures/Methods and User Defined Functions
© 2007 Lawrenceville Press Slide 1 Chapter 7 Top-Down Development  Problem-solving approach  Breaking a task down into smaller subtasks  First level.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Tutorial 11 Using and Writing Visual Basic for Applications Code
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 7 Sub and Function Procedures.
Chapter 6 Sub Procedures
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
IMS 3253: Subroutines 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Procedures Subroutines Parameters –By Value.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 4 - Visual Basic Schneider1 Chapter 4 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.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC PROGRAMMING FUNDAMENTALS Bilal Munir Mughal 1 Chapter-8.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
JavaScript, Fourth Edition
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Microsoft Visual Basic 2005 BASICS Lesson 3 Events and Code.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Week Procedures And Functions 7 A procedure is a collection of statements that performs a task.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Starting Out with Visual Basic.NET 2 nd Edition Chapter 6 Sub Procedures And Functions.
COM148X1 Interactive Programming Lecture 8. Topics Today Review.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
CS0004: Introduction to Programming
Sub Procedures And Functions
Programming Right from the Start with Visual Basic .NET 1/e
A variable is a name for a value stored in memory.
Chapter 4 The If…Then Statement
IS 350 Application Structure
Chapter 1: An Introduction to Visual Basic 2015
Multiple Classes and Inheritance
Chapter 7 Top-Down Development
Functions Chapter 6-Part 2.
Microsoft Access Illustrated
Using Procedures and Exception Handling
Chapter 2 Visual Basic Interface
Variables and Arithmetic Operations
Chapter 4 - Visual Basic Schneider
Chapter 5 The Do…Loop Statement
Can perform actions and provide communication
Chapter 3: Introduction to Problem Solving and Control Statements
Procedures and Functions
CIS16 Application Development and Programming using Visual Basic.net
Introduction to Visual Programming
Can perform actions and provide communication
Visual Basic: Week 5 Review User defined functions
Tonga Institute of Higher Education
Chapter 8 - Functions and Functionality
Introduction to VB programming
Web Programming and Design
Presentation transcript:

Chapter 6 Sub Procedures 11/16/2018 6:49 PM Chapter 6 Sub Procedures A set of statements that perform a specific task. Divide a program into smaller, more manageable blocks of code. An event procedure is written for a specific object event, while a sub procedure can perform tasks unrelated to any specific event. Procedure names should begin with an uppercase letter and then an uppercase letter should begin each word within the name. Executed by using a Call statement. Refer to page 163 in the text. © 2010 Lawrenceville Press

Chapter 6 The PictureBox Control 11/16/2018 6:49 PM Chapter 6 The PictureBox Control (Name) should begin with pic. Image is used to add images to the Resource folder with the selected image displayed in the picture box. SizeMode is typically set to AutoSize so that the picture box is automatically sized to the image size. Visible is set to False to hide an image at run time. Size changes automatically when SizeMode is AutoSize. Refer to page 164 in the text. A Click event procedure is sometimes coded for a picture box. © 2010 Lawrenceville Press

Chapter 6 Changing an Image at Run Time 11/16/2018 6:49 PM Chapter 6 Changing an Image at Run Time Images must be stored in the Resources folder in the project folder. The My.Resources object is used to access an image: My.pictureBox.Image = My.Resources.imageName Refer to page 165 in the text. © 2010 Lawrenceville Press

Chapter 6 The LinkLabel Control 11/16/2018 6:49 PM Chapter 6 The LinkLabel Control The LinkLabel Control is used to add a link to a website Refer to page 165 in the text. © 2010 Lawrenceville Press

Chapter 6 Value Parameters 11/16/2018 6:49 PM Chapter 6 Value Parameters A procedure can have parameters for accepting values from a calling statement. Parameters are used inside the procedure to perform the procedure's task. The data passed to a procedure are called the arguments. GiveHint() has two parameters: Sub GiveHint(ByVal firstNum As Integer, _ ByVal secondNum As Integer) … Refer to page 167 in the text. © 2010 Lawrenceville Press

Chapter 6 Value Parameters (cont.) 11/16/2018 6:49 PM Chapter 6 Value Parameters (cont.) The order of the arguments passed corresponds to the order of the parameters in the procedure heading. The number of arguments in a procedure call must match the number of parameters in the procedure declaration. Arguments passed by value can be in the form of constants, variables, values, or expressions. Variable arguments passed by value are not changed by the procedure. Refer to pages 167 and 168 in the text. © 2010 Lawrenceville Press

Chapter 6 Procedure Documentation 11/16/2018 6:49 PM Chapter 6 Procedure Documentation Procedure documentation should include a brief description of what the procedure does. Documentation should also include the assumptions, or initial requirements, of a procedure called preconditions (pre:). Documentation should include a postcondition (post:), which is what must be true at the end of the execution of a procedure if the procedure has worked properly. Refer to page 168 in the text. © 2010 Lawrenceville Press

Chapter 6 Reference Parameters 11/16/2018 6:49 PM Chapter 6 Reference Parameters Refer to page 170 in the text. © 2010 Lawrenceville Press

Chapter 6 Reference Parameters (cont.) 11/16/2018 6:49 PM Chapter 6 Reference Parameters (cont.) The order of the arguments passed corresponds to the order of the parameters in the procedure heading. ByRef parameters accept only variable arguments. Variable arguments passed by reference may be changed by the procedure. Refer to page 170 in the text. © 2010 Lawrenceville Press

Chapter 6 Control Object Parameters 11/16/2018 6:49 PM Chapter 6 Control Object Parameters Control objects are a data type called a control class. A control object can be passed as an argument to a procedure. Control argument parameters should be declared ByRef in a procedure using the appropriate class name. Refer to page 173 in the text. © 2010 Lawrenceville Press

Chapter 6 Event Handler Procedures 11/16/2018 6:49 PM Chapter 6 Event Handler Procedures Can be written to handle more than one event. Procedure name can be changed because the events after the Handles keyword is what indicates when the procedure will execute. Refer to page 174 in the text. © 2010 Lawrenceville Press

Chapter 6 The HotDog Application 11/16/2018 6:49 PM Chapter 6 The HotDog Application Refer to page 175 in the text. © 2010 Lawrenceville Press

Chapter 6 The Tag Property 11/16/2018 6:49 PM Chapter 6 The Tag Property Every control has a Tag property. Can be set to a string that is useful for identifying the object. When an event procedure is handling more than one object, the string in the Tag property can be used to determine which object raised the event. Refer to page 175 in the text. © 2010 Lawrenceville Press

Chapter 6 Function Procedures 11/16/2018 6:49 PM Chapter 6 Function Procedures A set of statements that perform a specific task and then return a value. Built-in functions include Int() and Rnd(). A function often has at least one parameter for data that is required to perform its task. Parameters are ByVal because a function returns a single value without changing argument values. Called from within an assignment statement or another type of statement that will make use of the returned value. Refer to pages 179 and 180 in the text. © 2010 Lawrenceville Press