SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Destaque

Web vulnerability seminar1
Web vulnerability seminar1Web vulnerability seminar1
Web vulnerability seminar1
Sakuya 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 Applications
Fatih Ozavci
 
EZ KEY_EZ
EZ KEY_EZEZ KEY_EZ
EZ KEY_EZ
Jaesung Lee
 

Destaque (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
 

Semelhante a Variables and constants

Modularisation techniques new
Modularisation techniques newModularisation techniques new
Modularisation techniques new
Jeet Thombare
 
System Programing Unit 1
System Programing Unit 1System Programing Unit 1
System Programing Unit 1
Manoj Patil
 

Semelhante a 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
 

Último

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
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
kauryashika82
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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.
 
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
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
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
 

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.

Notas do Editor

  1. Global variables across forms = variable in module