SlideShare a Scribd company logo
Visual Basic Chapter 6 - Procedures
Sub Procedures Sub Procedure - 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. Form:Sub ProcedureName()     statementsEnd Sub
Sub Procedures ProcedureName - A name describing the task performed by the procedure. Should indicate an action Should begin with an uppercase letter and then an uppercase letter should begin each word within the name  (Like standard variable declarations.) May not contain spaces Sub procedures divide a program into a smaller, more manageable blocks of code.
Sub Procedures Sub Procedures result in less code redundancy Statements for a specific task appear just once in the Sub procedure. Example on page 163 A Sub procedure must be called with a Call statement from another procedure in order to execute. ,[object Object],[object Object]
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 Form:My.pictureBox.Image = My.Resources.imageNamepictureBox- name of the PictureBox objectimageName- name of the resource in the Resources folder
The LinkLabel Control The LinkLabel Control is used to add a link to a website. (Name) should begin withlnk. ActiveLinkColor sets the color of the link when clicked. LinkColor sets the color of the link. Text sets the text for the destination website. VisitedLinkColor sets the color of a previously visited link.
Review: PetStorepage 165
Value Parameters A procedure often needs data in order to complete its task. pass - giving data to a procedure argument - a variable or value passed to a procedure Call GiveHint(secretNumber, guess) arguments: secretNumber, guess parameter - a variable declared in a procedure to accept the value or address of an argument
Value Parameters Parameters are used inside the procedure to perform the procedure's task. Form:Sub ProcedureName(ByValparameter1 As type, ...) statements End Sub ByVal- keyword used to declare a value parameter in a procedure or function.
Value Parameters value parameter -a variable declaration in a procedure to accept a copy of an argument. cannot alter the value of the actual arguments used in the procedure call. GiveHint() example - page 167 Remember when working with procedures that have value parameters: The order of the arguments passed corresponds to the order of the parameters in the procedure heading.
Value Parameters 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. Example: Demo() - page 168
Procedure Documentation Just as comments are used to clarify statements, comments should also be used to describe, or document, procedures. Procedure documentation should include a brief description of what the procedure does. Documentation should also include preconditions and postconditions. precondition - The initial requirements of a procedure (e.g. assumptions).  Also referred to as “pre”.
Procedure Documentation postcondition - A statement of what must be true at the end of the execution of a procedure if the procedure has worked properly.  Also referred to as “post”. Note: A procedure may not have a precondition, but every procedure must have a postcondition. Example: GiveHint() - pages 168-169
Review: GuessingGame - part 3 of 4page 169
Reference Parameters reference parameter - A variable declared in a procedure to accept to address of an argument. Can alter the value of the variable arguments used in the procedure call Form: Sub ProcedureName(ByRefparameter1 As type, ...) statements End Sub
Reference Parameters ByRef - Keyword used to declare a reference parameter in a procedure. Note: A procedure can have both reference (ByRef) and value (ByVal) parameters.Example:TwoDigits()- page 170 address - A variable’s location in memory where its value is stored. ,[object Object],[object Object]
Reference Parameters Keep in mind when working with procedures with reference parameters: 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.
Review: NumberBreakdownpage 171Review: SortNumberspage 173
Control Object Parameters Control objects, such as labels, are a data type called a control class. Includes CheckBox, Label, RadioButton, Button, TextBox and PictureBox controls. 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. Example: GiveHint() - page 174
Review: GuessingGame - part 4 of 4page 174
Event Handler Procedures Event procedures are used in every program. Called event handler procedures because they execute in response to an event. Can be written to handle more than one event. In the following example, the event procedure executes when the check box is clicked:
Event Handler Procedures Handles - Keyword that determines which events cause an event procedure to execute. Event procedure declarations include the Handles keyword followed by the events to be handled. The keyword, not the procedure name, determines when an event procedure executes. Therefore, changing an event procedure name has no effect on procedure execution. Event procedures handle multiple events when event names, separated by commas, are added after the Handles keyword.
Event Handler Procedures Event procedures always include two parameters: An object to raise the event Information about the event  chkRelish_Click example: ,[object Object]
e is the information about the eventObject - A data type that can be used to represent any value.
The HotDog Application
The Tag Property Every control has a Tag property. tag - Control class property that can be set to a string expression for identifying objects. 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. Important when different actions should be taken for different objects. Example: Page 176
Review: ShellGamepage 176
Function Procedures function - A set of statements that perform a specific task and then return a value. Built-in functions include Int() and Rnd(). Form:Function ProcedureName(ByValparameter1 As _ type, ...) As Returntypestatements   Return valueEnd Function Return - Statement used in a function procedure to send a value back to the calling statement.
Function Procedures Function Procedures are called from within an assignment statement or another type of statement that will make use of the returned value. Example:Me.lblStudentGrade.Text = LetterGrade(average) See page 180. Note: A function is a better choice over a Sub procedure when a well-defined task that results in a single value is to be performed.
Function Procedures Keep in mind the following when working with functions: The order of the arguments corresponds to the order of the parameters. Only ByVal parameters should be declared in a function because a function should not alter the arguments it has been passed. A function returns a single value and therefore must be used in a statement such as an assignment statement that makes use of the returned value.
Review: LetterGradepage 181
Coding Conventions Procedures names should indicate an action and begin with an uppercase letter and then an uppercase letter should begin each word within the name. Procedure documentation should include a brief description of the task the procedure performs, a precondition when needed, and a postcondition.
Case Study: CalculatorIIpage 182Review: CalculatorII 1 of 2page 189Review: CalculatorII 2 of 2page 189Review: TestRndIntFunctionpage 189
Chapter 6 slides

More Related Content

What's hot

Functions assignment
Functions assignmentFunctions assignment
Functions assignment
Ahmad Kamal
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
SabinDhakal13
 
4. function
4. function4. function
4. function
Shankar Gangaju
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
Harendra Singh
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
Krushal Kakadia
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
Prof. Dr. K. Adisesha
 
Function & Recursion
Function & RecursionFunction & Recursion
Function & Recursion
Meghaj Mallick
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
Deepak Singh
 
Function
FunctionFunction
Function
rishabh agrawal
 
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
gamemaker762
 
Qtp Presentation
Qtp PresentationQtp Presentation
Qtp Presentation
techgajanan
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
oswchavez
 
Python recursion
Python recursionPython recursion
Python recursion
Prof. Dr. K. Adisesha
 
Maximum Price Limitation
Maximum Price LimitationMaximum Price Limitation
Maximum Price Limitation
Rakesh Dasgupta
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Net
tjunicornfx
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
vinay chauhan
 
Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6
Notre Dame of Midsayap College
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
pragya ratan
 
Class 10
Class 10Class 10
Python - Lecture 2
Python - Lecture 2Python - Lecture 2
Python - Lecture 2
Ravi Kiran Khareedi
 

What's hot (20)

Functions assignment
Functions assignmentFunctions assignment
Functions assignment
 
Presentation of computer
Presentation of computerPresentation of computer
Presentation of computer
 
4. function
4. function4. function
4. function
 
User defined functions in C
User defined functions in CUser defined functions in C
User defined functions in C
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
Function & Recursion
Function & RecursionFunction & Recursion
Function & Recursion
 
Chapter 11 Function
Chapter 11 FunctionChapter 11 Function
Chapter 11 Function
 
Function
FunctionFunction
Function
 
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems Processes in Query Optimization in (ABMS) Advanced Database Management Systems
Processes in Query Optimization in (ABMS) Advanced Database Management Systems
 
Qtp Presentation
Qtp PresentationQtp Presentation
Qtp Presentation
 
Booa8 Slide 09
Booa8 Slide 09Booa8 Slide 09
Booa8 Slide 09
 
Python recursion
Python recursionPython recursion
Python recursion
 
Maximum Price Limitation
Maximum Price LimitationMaximum Price Limitation
Maximum Price Limitation
 
Procedures functions structures in VB.Net
Procedures  functions  structures in VB.NetProcedures  functions  structures in VB.Net
Procedures functions structures in VB.Net
 
Basics of cpp
Basics of cppBasics of cpp
Basics of cpp
 
Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6Understanding Subroutines and Functions in VB6
Understanding Subroutines and Functions in VB6
 
VB Function and procedure
VB Function and procedureVB Function and procedure
VB Function and procedure
 
Class 10
Class 10Class 10
Class 10
 
Python - Lecture 2
Python - Lecture 2Python - Lecture 2
Python - Lecture 2
 

Similar to Chapter 6 slides

Function & procedure
Function & procedureFunction & procedure
Function & procedure
atishupadhyay
 
Unit iii vb_study_materials
Unit iii vb_study_materialsUnit iii vb_study_materials
Unit iii vb_study_materials
gayaramesh
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
vekariyakashyap
 
Functions and Arguments in Python
Functions and Arguments in PythonFunctions and Arguments in Python
Functions and Arguments in Python
Mars Devs
 
procedures and arrays
procedures and arraysprocedures and arrays
procedures and arrays
DivyaR219113
 
Day2 j meter_training_script_enhancements
Day2 j meter_training_script_enhancementsDay2 j meter_training_script_enhancements
Day2 j meter_training_script_enhancements
Sravanthi N
 
Day2_Apache_JMeter_Script_Enhancements
Day2_Apache_JMeter_Script_EnhancementsDay2_Apache_JMeter_Script_Enhancements
Day2_Apache_JMeter_Script_Enhancements
Sravanthi N
 
Chapter 1. Functions in C++.pdf
Chapter 1.  Functions in C++.pdfChapter 1.  Functions in C++.pdf
Chapter 1. Functions in C++.pdf
TeshaleSiyum
 
Chapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfChapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdf
TeshaleSiyum
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
NabeelaNousheen
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
YOGESH SINGH
 
Savitch ch 04
Savitch ch 04Savitch ch 04
Savitch ch 04
Terry Yoast
 
Python-Functions.pptx
Python-Functions.pptxPython-Functions.pptx
Python-Functions.pptx
Karudaiyar Ganapathy
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
LidetAdmassu
 
Unit iv functions
Unit  iv functionsUnit  iv functions
Unit iv functions
indra Kishor
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
Tanmay Modi
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
Andi Simanjuntak
 
Subprogramms
SubprogrammsSubprogramms
Subprogramms
janapriyanaidu
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
Hattori Sidek
 

Similar to Chapter 6 slides (20)

Function & procedure
Function & procedureFunction & procedure
Function & procedure
 
Unit iii vb_study_materials
Unit iii vb_study_materialsUnit iii vb_study_materials
Unit iii vb_study_materials
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
 
Functions and Arguments in Python
Functions and Arguments in PythonFunctions and Arguments in Python
Functions and Arguments in Python
 
procedures and arrays
procedures and arraysprocedures and arrays
procedures and arrays
 
Day2 j meter_training_script_enhancements
Day2 j meter_training_script_enhancementsDay2 j meter_training_script_enhancements
Day2 j meter_training_script_enhancements
 
Day2_Apache_JMeter_Script_Enhancements
Day2_Apache_JMeter_Script_EnhancementsDay2_Apache_JMeter_Script_Enhancements
Day2_Apache_JMeter_Script_Enhancements
 
Chapter 1. Functions in C++.pdf
Chapter 1.  Functions in C++.pdfChapter 1.  Functions in C++.pdf
Chapter 1. Functions in C++.pdf
 
Chapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdfChapter_1.__Functions_in_C++[1].pdf
Chapter_1.__Functions_in_C++[1].pdf
 
Cpp functions
Cpp functionsCpp functions
Cpp functions
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Savitch ch 04
Savitch ch 04Savitch ch 04
Savitch ch 04
 
Python-Functions.pptx
Python-Functions.pptxPython-Functions.pptx
Python-Functions.pptx
 
Fundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programmingFundamental of programming Fundamental of programming
Fundamental of programming Fundamental of programming
 
Unit iv functions
Unit  iv functionsUnit  iv functions
Unit iv functions
 
Functions in c language
Functions in c languageFunctions in c language
Functions in c language
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Visualbasic tutorial
Visualbasic tutorialVisualbasic tutorial
Visualbasic tutorial
 
Subprogramms
SubprogrammsSubprogramms
Subprogramms
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 

Recently uploaded

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
Wahiba Chair Training & Consulting
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Denish Jangid
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 

Recently uploaded (20)

How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience How to Create a More Engaging and Human Online Learning Experience
How to Create a More Engaging and Human Online Learning Experience
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Chapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptxChapter wise All Notes of First year Basic Civil Engineering.pptx
Chapter wise All Notes of First year Basic Civil Engineering.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 

Chapter 6 slides

  • 1. Visual Basic Chapter 6 - Procedures
  • 2. Sub Procedures Sub Procedure - 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. Form:Sub ProcedureName() statementsEnd Sub
  • 3. Sub Procedures ProcedureName - A name describing the task performed by the procedure. Should indicate an action Should begin with an uppercase letter and then an uppercase letter should begin each word within the name (Like standard variable declarations.) May not contain spaces Sub procedures divide a program into a smaller, more manageable blocks of code.
  • 4.
  • 5. 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 Form:My.pictureBox.Image = My.Resources.imageNamepictureBox- name of the PictureBox objectimageName- name of the resource in the Resources folder
  • 6. The LinkLabel Control The LinkLabel Control is used to add a link to a website. (Name) should begin withlnk. ActiveLinkColor sets the color of the link when clicked. LinkColor sets the color of the link. Text sets the text for the destination website. VisitedLinkColor sets the color of a previously visited link.
  • 8. Value Parameters A procedure often needs data in order to complete its task. pass - giving data to a procedure argument - a variable or value passed to a procedure Call GiveHint(secretNumber, guess) arguments: secretNumber, guess parameter - a variable declared in a procedure to accept the value or address of an argument
  • 9. Value Parameters Parameters are used inside the procedure to perform the procedure's task. Form:Sub ProcedureName(ByValparameter1 As type, ...) statements End Sub ByVal- keyword used to declare a value parameter in a procedure or function.
  • 10. Value Parameters value parameter -a variable declaration in a procedure to accept a copy of an argument. cannot alter the value of the actual arguments used in the procedure call. GiveHint() example - page 167 Remember when working with procedures that have value parameters: The order of the arguments passed corresponds to the order of the parameters in the procedure heading.
  • 11. Value Parameters 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. Example: Demo() - page 168
  • 12. Procedure Documentation Just as comments are used to clarify statements, comments should also be used to describe, or document, procedures. Procedure documentation should include a brief description of what the procedure does. Documentation should also include preconditions and postconditions. precondition - The initial requirements of a procedure (e.g. assumptions). Also referred to as “pre”.
  • 13. Procedure Documentation postcondition - A statement of what must be true at the end of the execution of a procedure if the procedure has worked properly. Also referred to as “post”. Note: A procedure may not have a precondition, but every procedure must have a postcondition. Example: GiveHint() - pages 168-169
  • 14. Review: GuessingGame - part 3 of 4page 169
  • 15. Reference Parameters reference parameter - A variable declared in a procedure to accept to address of an argument. Can alter the value of the variable arguments used in the procedure call Form: Sub ProcedureName(ByRefparameter1 As type, ...) statements End Sub
  • 16.
  • 17. Reference Parameters Keep in mind when working with procedures with reference parameters: 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.
  • 19. Control Object Parameters Control objects, such as labels, are a data type called a control class. Includes CheckBox, Label, RadioButton, Button, TextBox and PictureBox controls. 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. Example: GiveHint() - page 174
  • 20. Review: GuessingGame - part 4 of 4page 174
  • 21. Event Handler Procedures Event procedures are used in every program. Called event handler procedures because they execute in response to an event. Can be written to handle more than one event. In the following example, the event procedure executes when the check box is clicked:
  • 22. Event Handler Procedures Handles - Keyword that determines which events cause an event procedure to execute. Event procedure declarations include the Handles keyword followed by the events to be handled. The keyword, not the procedure name, determines when an event procedure executes. Therefore, changing an event procedure name has no effect on procedure execution. Event procedures handle multiple events when event names, separated by commas, are added after the Handles keyword.
  • 23.
  • 24. e is the information about the eventObject - A data type that can be used to represent any value.
  • 26. The Tag Property Every control has a Tag property. tag - Control class property that can be set to a string expression for identifying objects. 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. Important when different actions should be taken for different objects. Example: Page 176
  • 28. Function Procedures function - A set of statements that perform a specific task and then return a value. Built-in functions include Int() and Rnd(). Form:Function ProcedureName(ByValparameter1 As _ type, ...) As Returntypestatements Return valueEnd Function Return - Statement used in a function procedure to send a value back to the calling statement.
  • 29. Function Procedures Function Procedures are called from within an assignment statement or another type of statement that will make use of the returned value. Example:Me.lblStudentGrade.Text = LetterGrade(average) See page 180. Note: A function is a better choice over a Sub procedure when a well-defined task that results in a single value is to be performed.
  • 30. Function Procedures Keep in mind the following when working with functions: The order of the arguments corresponds to the order of the parameters. Only ByVal parameters should be declared in a function because a function should not alter the arguments it has been passed. A function returns a single value and therefore must be used in a statement such as an assignment statement that makes use of the returned value.
  • 32. Coding Conventions Procedures names should indicate an action and begin with an uppercase letter and then an uppercase letter should begin each word within the name. Procedure documentation should include a brief description of the task the procedure performs, a precondition when needed, and a postcondition.
  • 33. Case Study: CalculatorIIpage 182Review: CalculatorII 1 of 2page 189Review: CalculatorII 2 of 2page 189Review: TestRndIntFunctionpage 189