CSC 162 Visual Basic I Programming. Storage Classes Determines the “lifetime” of an identifier Types: –Automatic Default Memory is allocated for the variable.

Slides:



Advertisements
Similar presentations
Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Advertisements

Pemrograman VisualMinggu …3… Page 1 MINGGU Ke Tiga Pemrograman Visual Pokok Bahasan: Class, Objects, Methods and Instance Variable Tujuan Instruksional.
Chapter 91 Scopes of Variables and JavaBeans JavaServer Pages By Xue Bai.
VBA Modules, Functions, Variables, and Constants
Lifetime “The lifetime of a variable is the time during which the variable is bound to a specific memory location.” [p. 219] “…the lifetime of a variable.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 04.
Fortran 9x HTML version. New F90 features Free source form Modules User-defined data types and operators Generic user-defined procedures Interface blocks.
Chapter 9: Subprogram Control
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.
C Lecture Notes Functions (Cont...). C Lecture Notes 5.8Calling Functions: Call by Value and Call by Reference Used when invoking functions Call by value.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
VB – Core III Functions Sub-routines Parameter passing Modules Scope Lifetime.
Storage Classes.
Scope.
1 Chapter 5: Names, Bindings and Scopes Lionel Williams Jr. and Victoria Yan CSci 210, Advanced Software Paradigms September 26, 2010.
1 Chapter 9 Scope, Lifetime, and More on Functions.
1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
C Functions Programmer-defined functions – Functions written by the programmer to define specific tasks. Functions are invoked by a function call. The.
Chapter 6: Modularity Using Functions. In this chapter, you will learn about: – Function and parameter declarations – Returning a single value – Returning.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
Access VBA Programming for Beginners - Class 2 - by Patrick Lasu
Storage Bindings Allocation is the process by which the memory cell or collection of memory cells is assigned to a variable. These cells are taken from.
More about Class 靜宜大學資工系 蔡奇偉副教授 ©2011. 大綱 Instance Class Members Class members can be associated with an instance of the class or with the class as a.
18. DECLARATIONS.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
 2007 Pearson Education, Inc. All rights reserved Random Number Generation  rand function – Load – Returns "random" number between
C++ Programming Lecture 11 Functions – Part III By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
ME 142 Engineering Computation I Using Subroutines Effectively.
Classes: user-defined types. Organizing method with a class A class is used to organize methods * Methods that compute Mathematical functions * The Scanner.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
#include using namespace std; // Declare a function. void check(int, double, double); int main() { check(1, 2.3, 4.56); check(7, 8.9, 10.11); } void check(int.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
Programming with Microsoft Visual Basic th Edition
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
Chapter 12: Programming in the Large By: Suraya Alias 1-1.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
# 1# 1 Nested If Statements in VBA What is a compound condition that we evaluate? What is a Nested If statement? How do we use ElseIf? CS 105 Spring 2010.
Sub Procedures; Passing Values Back From Sub Procedures Passing by reference Passing by value.
+ Storage Classes and Linkage. + Introduction Scope describe the region or regions of a program that can access and identifier Variables can be shared.
More on Variables and Subroutines. Introduction Discussion so far has dealt with self- contained subs. Subs can call other subs or functions. A module.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
CHAPTER 8 Scope, Lifetime, and More on Functions.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
1 Chapter 8 Scope, Lifetime, and More on Functions CS185/09 - Introduction to Programming Caldwell College.
CSC 162 Visual Basic I Programming. Selection Structures If/Then (single selection) If/Then/Else (double selection) If/Then/ElseIf (multiple selection)
Dynamic memory allocation and Intraprogram Communication.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Advanced Programming in C
Visual Basic I Programming
A variable is a name for a value stored in memory.
CS 326 Programming Languages, Concepts and Implementation
Object-Oriented Programming: Classes and Objects
Type Checking, and Scopes
Programming with ANSI C ++
SHARED MEMORY PROGRAMMING WITH OpenMP
Working with Forms in Visual Basic
Object-Oriented Programming: Classes and Objects
CSC 253 Lecture 8.
CSC 253 Lecture 8.
Scope, Visibility, and Lifetime
UNIT V Run Time Environments.
Intro to Programming Concepts
7-2 Multiplying powers with the same base.
Presentation transcript:

CSC 162 Visual Basic I Programming

Storage Classes Determines the “lifetime” of an identifier Types: –Automatic Default Memory is allocated for the variable when the procedure is executed and is destroyed at the termination of the procedure Variable loses value after each execution of the procedure –Static Memory is allocated for the variable when the program (form) is executed and is destroyed at the termination of the program (form) Variable retains value between each execution of the procedure

Static Storage Class Each variable can be declared to be static: Private Sub PrintNums() Static intA As Integer Static intB As Integer Dim intC As Integer ' Automatic storage class... End Sub –This is the preferred method, since it explicitly declares whether it is Automatic or Static. (Note: Static takes the place of Dim.) All variables can be declared to be static: Private Static Sub PrintNums() Dim intA As Integer Dim intB As Integer... End Sub –By using Static in the Procedure declaration, all variables are implicitly made Static.

Why use the Static storage class? Good for counters or timers that need to continue between executions.

Scope Rules Determines the region in which an identifier can be referenced Types: (from innermost to outermost level of scope) –Local Variable is only available in the procedure –Private (Module) Variable (or identifier) is only available in the module –Public Variable (or identifier) is available to all modules in the project When variables (or identifiers) within the same project have the same name, the one with the innermost scope has precedence. Instead of relying on precedence, use explicitly different names.

Classwork Program Trace Figure 6.15 (Pages ) Page 240 #6.40 (Together) Page 240 #6.41 (Individually) Homework Read Chapter ,