1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help.

Slides:



Advertisements
Similar presentations
Chapter 3: Using Variables and Constants Programming with Microsoft Visual Basic 2005, Third Edition.
Advertisements

Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
VBA Modules, Functions, Variables, and Constants
Slide 1 Variables, Constants and Data Types. Slide 2 Variables v Three components define a variable: –Name (memory location) –Type –Information (value)
Visual Basic: An Object Oriented Approach 4: Simple Programming in VB.
Data Types and Operations Programming Fundamentals (Writing Code)Programming Fundamentals (Writing Code)
1 Pertemuan 03 Representing Data Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
ITP 150 Week 4 Variables. ITP Lecturer: A. Borquez2 Review:  Controls  Propeties  Events  Methods  Procedures  Functions BackStyleFillColor.
VB .NET Programming Fundamentals
Chapter Three Using Variables and Constants Programming with Microsoft Visual Basic th Edition.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
Chapter 3: Using Variables and Constants
Programming with Microsoft Visual Basic th Edition CHAPTER THREE USING VARIABLES AND CONSTANTS.
JavaScript, Fifth Edition Chapter 1 Introduction to JavaScript.
CIS Computer Programming Logic
Tutorial 11 Using and Writing Visual Basic for Applications Code
ECE 2372 Modern Digital System Design
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Why to Create a Procedure
CHAPTER THREE Representing Data: Constants and Variables.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 11 Committed to Shaping the Next Generation of IT Experts. Chapter 10 Customizing a Database.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Lecture Set 11 Creating and Using Classes Part B – Class Features – Constructors, Methods, Fields, Properties, Shared Data.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
Chapter 3 P. 1 Data - Variables and Constants Definition A variable is a value which can change during program execution. A constant is a value which can.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC PROGRAMMING FUNDAMENTALS Bilal Munir Mughal 1 Chapter-8.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Three Using Variables and Constants.
Chapter 10: Classes and Data Abstraction. Objectives In this chapter, you will: Learn about classes Learn about private, protected, and public members.
Visual Basic Programming I 56:150 Information System Design.
CHAPTER SIX Reducing Program Complexity General Sub Procedures and Developer-defined Functions.
Programming with Microsoft Visual Basic th Edition
Visual Basic CDA College Limassol Campus COM123 Visual Programming 1 Semester B Lecture:Pelekanou Olga Week 5: Useful Functions and Procedures.
By Mr. Muhammad Pervez Akhtar
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
Visual Basic CDA College Limassol Campus COM123 Visual Basic Programming Semester C Lecture:Pelekanou Olga Week 3: Using Variables.
CHAPTER THREE Representing Data: Constants and Variables.
Chapter 10: Classes and Data Abstraction. Classes Object-oriented design (OOD): a problem solving methodology Objects: components of a solution Class:
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
Programming with Microsoft Visual Basic 2012 Chapter 3: Using Variables and Constants.
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.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 9: Value-Returning Functions
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
Functions and an Introduction to Recursion
Object-Oriented Programming: Classes and Objects
Type Checking, and Scopes
Variables and Arithmetic Operations
C Language VIVA Questions with Answers
2. Understanding VB Variables
Microsoft Access Illustrated
Object-Oriented Programming: Classes and Objects
Lecture Set 4 Data Types and Variables
Variables and Arithmetic Operations
Chapter 6 Variables What is VBScript?
CIS16 Application Development Programming with Visual Basic
PHP.
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Presentation transcript:

1 VBA – podstawowe reguły języka Opracowanie Janusz Górczyński wg Microsoft Help

2 Visual Basic Naming Rules Use the following rules when you name procedures, constants, variables, and arguments in a Visual Basic module:proceduresconstants variablesargumentsmodule You must use a letter as the first character. You can't use a space, period (.), exclamation mark (!), or the &, $, # in the name. Name can't exceed 255 characters in length.

3 Visual Basic Naming Rules Generally, you shouldn't use any names that are the same as the functions, statements, and methods in Visual Basic.functionsstatementsmethods You end up shadowing the same keywords in the language. To use an intrinsic language function, statement, or method that conflicts with an assigned name, you must explicitly identify it.keywords Precede the intrinsic function, statement, or method name with the name of the associated type library.type library

4 Visual Basic Naming Rules For example, if you have a variable called Left, you can only invoke the Left function using VBA.Left. You can't repeat names within the same level of scope. For example, you can't declare two variables named age within the same procedure. However, you can declare a private variable named age and a procedure-level variable named age within the same module.scopeprocedure-level Note Visual Basic isn't case-sensitive, but it preserves the capitalization in the statement where the name is declared.

5 Procedure A named sequence of statements executed as a unit. For example, Function, Property, and Sub are types of procedures. A procedure name is always defined at module level. All executable code must be contained in a procedure. Procedures can't be nested within other procedures.

6 Constant A named item that retains a constant value throughout the execution of a program. A constant can be a string or numeric literal, another constant, or any combination that includes arithmetic or logical operators except Is and exponentiation. Each host application can define its own set of constants. Additional constants can be defined by the user with the Const statement. You can use constants anywhere in your code in place of actual values.

7 Variable A named storage location that can contain data that can be modified during program execution. Each variable has a name that uniquely identifies it within its scope. A data type can be specified or not. Variable names must begin with an alphabetic character, must be unique within the same scope, can't be longer than 255 characters, and can't contain an embedded period or type-declaration character.

8 Argument & module Argument A constant, variable, or expression passed to a procedure. Module A set of declarations followed by procedures.

9 Function procedure A procedure that performs a specific task within a program and returns a value. A Function procedure begins with a Function statement and ends with an End Function statement. For example: Function MojaF(t as String) as Integer..... End Function

10 Statement A syntactically complete unit that expresses one kind of action, declaration, or definition. A statement generally occupies a single line, although you can use a colon (:) to include more than one statement on a line. You can also use a line-continuation character (_) to continue a single logical line onto a second physical line.

11 Method & keyword Method A procedure that acts on an object. Keyword A word or symbol recognized as part of the Visual Basic programming language; for example, a statement, function name, or operator.

12 Type library A file or component within another file that contains standard descriptions of exposed objects, properties, and methods that are available for Automation. Object library files (.olb) contain type libraries.

13 Scope Defines the visibility of a variable, procedure, or object. For example, a variable declared as Public is visible to all procedures in all modules in a directly referencing project unless Option Private Module is in effect. When Option Private Module is in effect, the module itself is private and therefore not visible to referencing projects. Variables declared in a procedure are visible only within the procedure and lose their value between calls unless they are declared Static.

14 Procedure level Describes statements located within a Function, Property, or Sub procedure. Declarations are usually listed first, followed by assignments and other executable code. Note that module-level code resides outside a procedure block.