SlideShare une entreprise Scribd logo
1  sur  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.

Contenu connexe

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 

Dernier (20)

HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
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
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

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.

Notes de l'éditeur

  1. Global variables across forms = variable in module