Procedures Stefano Grazioli.

Slides:



Advertisements
Similar presentations
Introduction to File I/O How to read & write data to a disk file...
Advertisements

Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Computer Science 1620 Function Scope & Global Variables.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
Visual Basic: An Object Oriented Approach 4: Simple Programming in VB.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
Guide To UNIX Using Linux Third Edition
Promoting Code Reuse Often in programming, multiple procedures will perform the same operation IN OTHER WORDS – the same piece of code will do the same.
VB – Core III Functions Sub-routines Parameter passing Modules Scope Lifetime.
Adding Automated Functionality to Office Applications.
Financial Information Management Stefano Grazioli.
Financial Information Management Managing Financial Information Critical Thinking Business Process Modeling WINIT Control Structures Homework.
Languages and Environments Higher Computing Unit 2 – Software Development.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Financial Information Management DBMS and Operations, BI, and Analytics Stefano Grazioli.
IE 212: Computational Methods for Industrial Engineering
Tutorial 11 Using and Writing Visual Basic for Applications Code
CSC 107 – Programming For Science. Today’s Goal  Discuss writing & using functions  How to declare them, use them, & trace them  Could write programs.
Procedures and Functions Computing Module 1. What is modular programming? Most programs written for companies will have thousands of lines of code. Most.
Variable Scope Storage Class Recursion
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
Chapter 9: Writing Procedures Visual Basic.NET Programming: From Problem Analysis to Program Design.
Financial Information Management Putting VB & SQL To Work Stefano Grazioli.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 7 Structured Data and Classes.
I Power Higher Computing Software Development Development Languages and Environments.
Creating Macros in Excel Adding Automated Functionality to Excel & Office Applications.
ME 142 Engineering Computation I Using Subroutines Effectively.
Lecture 10: Modular Programming (functions) B Burlingame 13 April 2015.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
ME 142 Engineering Computation I Using Subroutines Effectively.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
More on Variables and Subroutines. Introduction Discussion so far has dealt with self- contained subs. Subs can call other subs or functions. A module.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
FUNCTIONS (C) KHAERONI, M.SI. OBJECTIVE After this topic, students will be able to understand basic concept of user defined function in C++ to declare.
1 This week Basics of functions Stack frames Stack vs. Heap (brief intro) Calling conventions Storage classes vs. scope Library functions Overloading.
Financial Information Management VB, VBA, VS, VSTO & VBE: Putting it all together Source: Excel VBA Programming by John Walkenbach.
© Stefano Grazioli - Ask for permission for using/quoting: Source: Excel VBA Programming by John Walkenbach.
© Stefano Grazioli - Ask for permission for using/quoting: Stefano Grazioli.
CS0004: Introduction to Programming
Sub Procedures Chapter 6-Part 1. Chapter 6 Part 12 Event Procedures Code that occurs based upon event. Mouse click Got focus Repetitive code that might.
Process Automation The Technology
Process Automation The Technology
Dropbox Basics.
Value-Returning Functions
Functions, locals, parameters, and separate compilation
Dynamic SQL Queries Stefano Grazioli.
Organization of Programming Languages
Topics Introduction to Repetition Structures
Lecture 11 B Methods and Data Passing
Introduction to Classes
Creating Macros in Excel
Functions, Procedures, and Abstraction
Dynamic SQL Queries Stefano Grazioli.
CS285 Introduction - Visual Basic
Process Automation: From models to code
Loops, Subs, & Functions Stefano Grazioli.
BI and data quality Stefano Grazioli.
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Loops, Subs, & Functions Stefano Grazioli.
Dynamic SQL Queries Stefano Grazioli.
Dynamic SQL Queries Stefano Grazioli.
Topics Introduction to Repetition Structures
BI and data quality Stefano Grazioli.
Functions, Procedures, and Abstraction
Introduction to Computer Programming IT-104
Programming Techniques
Presentation transcript:

Procedures Stefano Grazioli

Critical Thinking “Recording” error Extra credit (+1 point) to the first person who finds any material mistake in the vLabs or deck. Email timestamp will tell. Alternative ways of doing things do not count as errors. Easy meter  $100 @500% x 10 year

Renaming a Project Unzip & make a copy of the project folder Look inside the folder. Find the folder that contains the .vbproj file and many other files. Keep that folder, delete the ‘outer’ stuff. Change the folder name to the new name. Click on .vbproj to start VS and change all other filenames from inside VS.

You do the talking Name, Major Learning objectives What you like about the class What can be improved Attitude towards the Tournament

Procedures Lasagne and Tagliatelle

Subs are a type of procedure Public Sub MyProcedure() Dim inputFromUser As String = "" Dim userNum As Double = 0 inputFromUser = InputBox("Please enter a number to square") userNum = Double.Parse(inputFromUser) userNum = userNum ^ 2 ShowTheUser(userNum) End Sub Private Sub ShowTheUser(someValue As Double) Range(“A1”).Value = "The result is " + someValue.ToString("N0") A procedure is a named sequence of steps Purpose: reuse & simplify existing code Good practice: shorter than a single screen Sometimes it takes arguments “Macro” is the old name for procedure

Local and global variables Dim userNum As Double = 0 Public Sub MyProcedure() Dim inputFromUser As String = "" inputFromUser = InputBox("Please enter a number to square") userNum = Double.Parse(inputFromUser) userNum = userNum ^ 2 ShowTheUser(userNum) End Sub Private Sub ShowTheUser(someValue As Double) Range(“A1”).Value = "The result is " + someValue.ToString("N0") Variables are names for physical places in your computer memory Variables have a lifecycle Variables have a scope Find the vars in here

Functions are another type of procedure input Return a single value Conceptually similar to the formulas in your worksheets output Private Function CalcInterest(r As Double, principal As Double, t As Double) As Double Dim interest As Double = 0 interest = principal * ((((1 + r) ^ t) - 1)) Return interest End Function

Argument Binding ‘ A function Sometimes difficult to understand for beginners ‘ A function Private Function CalcInterest(r As Double, principal As Double, t As Double) As Double … ‘ No binding myInt = CalcInterest(0.05, 1000, 10) ‘ With binding (typical use) myRate = 0.10 userPrincipal = 8000 years = 20 myInt = CalcInterest(myRate, userPrincipal, years)

Arguments vs. Globals Arguments are short-term variables used as input to procedures (Subs and functions) -best practice -more efficient & less errors Globals are variables defined outside of a Sub/Function -Use globals if variables have an extended life, are small, and are used by many procedures

WINIT What Is New In Technology?

Homework Using Subs & Functions