SlideShare a Scribd company logo
1 of 13
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

Viewers also liked

How to find_vulnerability_in_software
How to find_vulnerability_in_softwareHow to find_vulnerability_in_software
How to find_vulnerability_in_softwaresanghwan ahn
 
Web vulnerability seminar4
Web vulnerability seminar4Web vulnerability seminar4
Web vulnerability seminar4Sakuya Izayoi
 
Codegate 2013 Junior - Music Player Exploit
Codegate 2013 Junior - Music Player ExploitCodegate 2013 Junior - Music Player Exploit
Codegate 2013 Junior - Music Player Exploitsweetchip
 
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015
Browser Fuzzing with a Twist (and a Shake) -- ZeroNights 2015Jeremy Brown
 
Web vulnerability seminar1
Web vulnerability seminar1Web vulnerability seminar1
Web vulnerability seminar1Sakuya Izayoi
 
취약점(Vulnerability) db 구조 설명
취약점(Vulnerability) db 구조 설명취약점(Vulnerability) db 구조 설명
취약점(Vulnerability) db 구조 설명eungjin cho
 
MBFuzzer : MITM Fuzzing for Mobile Applications
MBFuzzer : MITM Fuzzing for Mobile ApplicationsMBFuzzer : MITM Fuzzing for Mobile Applications
MBFuzzer : MITM Fuzzing for Mobile ApplicationsFatih Ozavci
 
Web vulnerability seminar2
Web vulnerability seminar2Web vulnerability seminar2
Web vulnerability seminar2Sakuya Izayoi
 
Inc0gnito fuzzing for_fun_sweetchip
Inc0gnito fuzzing for_fun_sweetchipInc0gnito fuzzing for_fun_sweetchip
Inc0gnito fuzzing for_fun_sweetchipsweetchip
 
Fuzzing underestimated method of finding hidden bugs
Fuzzing underestimated method of finding hidden bugsFuzzing underestimated method of finding hidden bugs
Fuzzing underestimated method of finding hidden bugsPawel Rzepa
 
[2014 CodeEngn Conference 10] 심준보 - 급전이 필요합니다
[2014 CodeEngn Conference 10] 심준보 -  급전이 필요합니다[2014 CodeEngn Conference 10] 심준보 -  급전이 필요합니다
[2014 CodeEngn Conference 10] 심준보 - 급전이 필요합니다GangSeok Lee
 
FUZZING & SOFTWARE SECURITY TESTING
FUZZING & SOFTWARE SECURITY TESTINGFUZZING & SOFTWARE SECURITY TESTING
FUZZING & SOFTWARE SECURITY TESTINGMuH4f1Z
 

Viewers also liked (15)

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

Similar to Variables and constants

Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques newJeet Thombare
 
An intuitive guide to combining free monad and free applicative
An intuitive guide to combining free monad and free applicativeAn intuitive guide to combining free monad and free applicative
An intuitive guide to combining free monad and free applicativeCameron Joannidis
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system softwaregayathri ravi
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptAmanuelZewdie4
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189Mahmoud Samir Fayed
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examplesAbdii Rashid
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Javanandanrocker
 
Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issueJigisha Pandya
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1Manoj Patil
 
The Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelFThe Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelFMarkus Voelter
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1guest38bf
 

Similar to Variables and constants (20)

Scope of variable
Scope of variableScope of variable
Scope of variable
 
Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
 
An intuitive guide to combining free monad and free applicative
An intuitive guide to combining free monad and free applicativeAn intuitive guide to combining free monad and free applicative
An intuitive guide to combining free monad and free applicative
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system software
 
Chapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.pptChapter Introduction to Modular Programming.ppt
Chapter Introduction to Modular Programming.ppt
 
Coding
CodingCoding
Coding
 
The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189The Ring programming language version 1.6 book - Part 6 of 189
The Ring programming language version 1.6 book - Part 6 of 189
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
C programming
C programmingC programming
C programming
 
Mobile Application Development class 001
Mobile Application Development class 001Mobile Application Development class 001
Mobile Application Development class 001
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Java
 
Ch1 language design issue
Ch1 language design issueCh1 language design issue
Ch1 language design issue
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
 
Ms vb
Ms vbMs vb
Ms vb
 
The Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelFThe Design, Evolution and Use of KernelF
The Design, Evolution and Use of KernelF
 
Chapter-3 Scoping.pptx
Chapter-3 Scoping.pptxChapter-3 Scoping.pptx
Chapter-3 Scoping.pptx
 
FUNCTIONS.pptx
FUNCTIONS.pptxFUNCTIONS.pptx
FUNCTIONS.pptx
 
Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1AVB201.1 MS Access VBA Module 1
AVB201.1 MS Access VBA Module 1
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

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

  1. Global variables across forms = variable in module