SlideShare a Scribd company logo
Bug Hunt Starter
• Use your developing
  knowledge of VB to find
  and correct the errors in
  the example program.
Objectives
• Identify the scope of variables and distinguish
  between local and global identifiers

• Identify and explain the use of constants and
  variables in algorithms and programs.
Variables (general)
• A variable is a name used to refer to a particular
  memory location that is used to store data

• Value can change while the program is running.

• Purpose if to allow the programmer to write code
  that manipulates the data without knowing, yet,
  what the data will be.
What data types that can be
  applied to variables?

String             Integer                Byte




Long               Double                Decimal




         Boolean             Date/Time
Types of variables
         • Declared at the beginning of the
           code and is available throughout
Global     the code, including all its
           subroutines.




         • Declared and used inside a
           module or subroutine and is only
Local      available in the module. Created
           when subroutine is called and
           destroyed when subroutine exits.
Program
Global      Form 1

 Local   Sub Procedure

 Local   Sub Procedure

 Local   Sub Procedure

 Local   Sub Procedure
Program
Global (to form)          Form 1   Global (to form)      Form 2

 Local             Sub Procedure    Local         Sub Procedure

 Local             Sub Procedure    Local         Sub Procedure

 Local             Sub Procedure    Local         Sub Procedure

 Local             Sub Procedure    Local         Sub Procedure
Program
Global (to form)   Form 1    Global (to form)   Form 2    Global (all)    Module

  Local      Sub Procedure     Local      Sub Procedure     Local        Function

  Local      Sub Procedure     Local      Sub Procedure     Local        Function

  Local      Sub Procedure     Local      Sub Procedure

  Local      Sub Procedure     Local      Sub Procedure
In action…
Variables top tips!
Use of spaces is not allowed. Use underscore or capitalisation
to make variables easier to spot. E.g. TimeOfArrival or
Time_of_Arrival

Give them sensible names, avoiding reserved words (IF, END,
OR, PRINT)


Use prefixes to help you remember data type e.g.
strFirstname, intAge



Select an appropriate data type – why?
Test yourself
1. What statement do you use to declare a local
   variable in VB?
2. What statement do you use to declare a global
   variable in VB?
3. What operator do you use to assign a value to a
   variable?
4. In terms of security, why is a local variable better
   than a global variable?
5. How should I create a variable that can we used
   program wide and available to all forms?
Constants
• Used where values will not change

• Examples?

Declared as:
        Const Public VAT as Decimal = 17.5

• Doesn’t require program to lookup value, always
  known – time efficient.
In summary..

Global Variables: a variable declared at the
beginning of a program and accessible from
anywhere in the program

Local Variable: a variable declared in a program
block & accessible only within the program block

Constant: a value that does not change throughout
the program.

More Related Content

PPTX
Guerrero rullan ppt
PPTX
Monolithic and Procedural Programming
PDF
The pseudocode
PPT
Unit 3 principles of programming language
PPTX
Code: from Procedural to Object Oriented
PPTX
Algorithms and flow charts
PPTX
Web vulnerability seminar3
PDF
Software Security - Vulnerability&Attack
Guerrero rullan ppt
Monolithic and Procedural Programming
The pseudocode
Unit 3 principles of programming language
Code: from Procedural to Object Oriented
Algorithms and flow charts
Web vulnerability seminar3
Software Security - Vulnerability&Attack

Viewers also liked (15)

PDF
How to find_vulnerability_in_software
PPTX
Web vulnerability seminar4
PDF
Fuzzing sucks!
PDF
Codegate 2013 Junior - Music Player Exploit
PPTX
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015
PDF
Web vulnerability seminar1
PDF
취약점(Vulnerability) db 구조 설명
PDF
MBFuzzer : MITM Fuzzing for Mobile Applications
PPTX
Web vulnerability seminar2
PDF
Inc0gnito fuzzing for_fun_sweetchip
PPTX
0-knowledge fuzzing
PDF
Fuzzing underestimated method of finding hidden bugs
PPTX
EZ KEY_EZ
PDF
[2014 CodeEngn Conference 10] 심준보 - 급전이 필요합니다
PDF
FUZZING & SOFTWARE SECURITY TESTING
How to find_vulnerability_in_software
Web vulnerability seminar4
Fuzzing sucks!
Codegate 2013 Junior - Music Player Exploit
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015
Web vulnerability seminar1
취약점(Vulnerability) db 구조 설명
MBFuzzer : MITM Fuzzing for Mobile Applications
Web vulnerability seminar2
Inc0gnito fuzzing for_fun_sweetchip
0-knowledge fuzzing
Fuzzing underestimated method of finding hidden bugs
EZ KEY_EZ
[2014 CodeEngn Conference 10] 심준보 - 급전이 필요합니다
FUZZING & SOFTWARE SECURITY TESTING
Ad

Similar to Variables and constants (20)

PPTX
Lab1GoBasicswithgo_foundationofgolang.pptx
PPTX
GlobalLocal_ExceptionHndlng_InPython.pptx
PPTX
LOCAL VARIABLES AND GLOBAL VARIABLES.pptx
PPTX
Modularisation techniques new
PDF
An intuitive guide to combining free monad and free applicative
PPTX
Debuggers in system software
PPT
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
PPT
Chapter Introduction to Modular Programming.ppt
PPT
Coding
PPTX
Introduction to Java.pptx sjskmdkdmdkdmdkdkd
PPTX
Lec 2 Compiler, Interpreter, linker, loader.pptx
PDF
The Ring programming language version 1.6 book - Part 6 of 189
PPTX
object oriented programming examples
PPTX
MODULE 2.pptx Python data handling types function
PPTX
C programming
PPTX
Mobile Application Development class 001
DOC
Grade 8: Introduction To Java
PPTX
Ch1 language design issue
PPTX
System Programing Unit 1
Lab1GoBasicswithgo_foundationofgolang.pptx
GlobalLocal_ExceptionHndlng_InPython.pptx
LOCAL VARIABLES AND GLOBAL VARIABLES.pptx
Modularisation techniques new
An intuitive guide to combining free monad and free applicative
Debuggers in system software
chapterintroductiontomodularprogramming-230112092330-e3eb5a74 (1).ppt
Chapter Introduction to Modular Programming.ppt
Coding
Introduction to Java.pptx sjskmdkdmdkdmdkdkd
Lec 2 Compiler, Interpreter, linker, loader.pptx
The Ring programming language version 1.6 book - Part 6 of 189
object oriented programming examples
MODULE 2.pptx Python data handling types function
C programming
Mobile Application Development class 001
Grade 8: Introduction To Java
Ch1 language design issue
System Programing Unit 1
Ad

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
Basic Mud Logging Guide for educational purpose
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Sports Quiz easy sports quiz sports quiz
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
Pharma ospi slides which help in ospi learning
Basic Mud Logging Guide for educational purpose
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
TR - Agricultural Crops Production NC III.pdf
GDM (1) (1).pptx small presentation for students
Sports Quiz easy sports quiz sports quiz
O5-L3 Freight Transport Ops (International) V1.pdf
Computing-Curriculum for Schools in Ghana
Anesthesia in Laparoscopic Surgery in India
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Structure & Organelles in detailed.
Module 4: Burden of Disease Tutorial Slides S2 2025

Variables and constants

  • 1. Bug Hunt Starter • Use your developing knowledge of VB to find and correct the errors in the example program.
  • 2. Objectives • Identify the scope of variables and distinguish between local and global identifiers • Identify and explain the use of constants and variables in algorithms and programs.
  • 3. Variables (general) • A variable is a name used to refer to a particular memory location that is used to store data • Value can change while the program is running. • Purpose if to allow the programmer to write code that manipulates the data without knowing, yet, what the data will be.
  • 4. What data types that can be applied to variables? String Integer Byte Long Double Decimal Boolean Date/Time
  • 5. Types of variables • Declared at the beginning of the code and is available throughout Global the code, including all its subroutines. • Declared and used inside a module or subroutine and is only Local available in the module. Created when subroutine is called and destroyed when subroutine exits.
  • 6. Program Global Form 1 Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure
  • 7. Program Global (to form) Form 1 Global (to form) Form 2 Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure
  • 8. Program Global (to form) Form 1 Global (to form) Form 2 Global (all) Module Local Sub Procedure Local Sub Procedure Local Function Local Sub Procedure Local Sub Procedure Local Function Local Sub Procedure Local Sub Procedure Local Sub Procedure Local Sub Procedure
  • 10. Variables top tips! Use of spaces is not allowed. Use underscore or capitalisation to make variables easier to spot. E.g. TimeOfArrival or Time_of_Arrival Give them sensible names, avoiding reserved words (IF, END, OR, PRINT) Use prefixes to help you remember data type e.g. strFirstname, intAge Select an appropriate data type – why?
  • 11. Test yourself 1. What statement do you use to declare a local variable in VB? 2. What statement do you use to declare a global variable in VB? 3. What operator do you use to assign a value to a variable? 4. In terms of security, why is a local variable better than a global variable? 5. How should I create a variable that can we used program wide and available to all forms?
  • 12. Constants • Used where values will not change • Examples? Declared as: Const Public VAT as Decimal = 17.5 • Doesn’t require program to lookup value, always known – time efficient.
  • 13. In summary.. Global Variables: a variable declared at the beginning of a program and accessible from anywhere in the program Local Variable: a variable declared in a program block & accessible only within the program block Constant: a value that does not change throughout the program.

Editor's Notes

  • #7: Global variables across forms = variable in module