SlideShare a Scribd company logo
CHAPTER-03
Variable
Constants
Culculation
Prepared by: Mr Pork Naron
Objective
 The student will be able to:
 What is Variable, constant
 Know how to declare variable and Constant
 Rule of naming variable and Constant
 Using Data type
 Scope of Variable and Constant
 Converting data output
 Format output
 Develop small project using calculator
Prepared by: Mr Pork Naron
Variable
 Provide a means to store data values that are
not stored in files.
 Support the computation of values through
their use in formulas in assignment
 Represent locations in a computer's memory
 are assigned a unique name for reference when
writing computer code statements.
Prepared by: Mr Pork Naron
DataType
Prepared by: Mr Pork Naron
DataType Description Bytes
Text Data
String Alphanumeric data such as letters of the alphabet Size varies
Char
Stores single Unicode characters (supports any international
language).
2
Numeric Data
Decimal often used to store dollars/cents 16
Double Double-precision numeric values with 14 digits of accuracy 8
Single Single-precision numeric values with 6 digits of accuracy 4
Short numeric values in the range -32,768 to 32,767 2
Integer
numeric values in the range -2,147,483,648 to
+2,147,483,647
4
Long numeric values that are very, very large 8
DataType(Cont)
Prepared by: Mr Pork Naron
DataType Description Bytes
Special DataType
Boolean True or False 2
Byte
Stores binary data of values 0 to 255 – can be used to store
ASCIIcharacter code values
1
Date Stores dates in the form 1/1/0001 to 12/31/9999 8
Object Any type of data 4
Naming Rules for
Variable and Constant
Prepared by: Mr Pork Naron
 Can be letters, digits, and the underscore,
but must begin with a letter
 cannot contain spaces or periods
 cannot be VB reserved words such as LET,
PRINT, DIM, or CONST
 are not case sensitive. This means that
TotalInteger, TOTALINTEGER, and
totalinteger are all equivalent names
Naming Convention
Prepared by: Mr Pork Naron
 Create meaningful names
 Avoid using abbreviations
 Begin each name with an uppercase letter and
capitalize each successive word in the name.
 Use mixed case (such as AmountDueDecimal) for
variables – use Uppercase for constant names
(such as TAX_RATE_SINGLE)
Declaring Variable & Constant
Prepared by: Mr Pork Naron
Variable
 Dim
 Eg: Dim EmployeeName as String
Constant
 Const
 Eg: Const Age as Integer=23
Scope of Variables and Constants
Prepared by: Mr Pork Naron
 Namespace : Public Shared(visible in whole
project)
 Module level: Private(variable), Const (
constant) – visile any procedure in specific form.
 Local : Dim(variable), Const (constant) visible
in only one procedure
 Block : Dim(variable), Const(constant) – visible
in only a portion of procedure
Converting Input Data Types
Prepared by: Mr Pork Naron
 Text property – always stores string
values, even if the string looks like a
number.
 Parse method – converts a value from
a Text property to an equivalent
numeric value or other types
Converting Variable Values to Output
Data Types
Prepared by: Mr Pork Naron
 Use (.ToString) method to convert
variable value to output data
 TxtOutput.text = Output.ToString()
Arithmetic Operators
Prepared by: Mr Pork Naron
 + Addition
 - Subtraction
 * Multiplication
 / Division
 ^ Exponentiation
  Integer Division
 Mod Modulus Division
Order of Precedence
Prepared by: Mr Pork Naron
1. Values enclosed inside
parentheses (xxxx)
2. Exponentiation ^
3. Multiplication and Division(*,/)
4. Addition and Subtraction (+, -)
Order of Precedence(cont)
Prepared by: Mr Pork Naron
Eg: Assume that: X=2, Y=4, and Z=3
Order of Precedence(cont)
Prepared by: Mr Pork Naron
• mathematical notation and the equivalent VB
expression
Format Function
Prepared by: Mr Pork Naron
 FormatCurrency
 BalanceDueTextBox.Text = FormatCurrency(BalanceDueDecimal)
 FormatNumber
 AmountTextBox.Text = FormatNumber(AmountDouble)
 FormatPercent
 PercentFinishedTextBox.Text = FormatPercent(FinishedSingle)
 FormatDate
 DateTextBox.Text = FormatDateTime(StartDate, DateFormat.ShortDate)
 DateTextBox.Text = FormatDateTime(StartDate, DateFormat.LongDate)
 TimeTextBox.Text = FormatDateTime(StartDateTime,
DateFormat.ShortTime)
 TimeTextBox.Text = FormatDateTime(StartDateTime,
DateFormat.LongTime)
Compute Lab
Prepared by: Mr Pork Naron
Develop Small Calculator

More Related Content

What's hot

TextBox and RichTextBox in VB.Net
TextBox and RichTextBox in VB.NetTextBox and RichTextBox in VB.Net
TextBox and RichTextBox in VB.Net
Saniya Saher
 
Effective Java - Always override toString() method
Effective Java - Always override toString() methodEffective Java - Always override toString() method
Effective Java - Always override toString() method
Ferdous Mahmud Shaon
 
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
Paris Women in Machine Learning and Data Science
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N Correction
Ankan Adhikari
 
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit ModelSingle-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
Universitas Pembangunan Panca Budi
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
KRUNAL RAVAL
 
..Ans 1
..Ans 1..Ans 1
..Ans 1
Vimmi Kaushal
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
ASIT
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
Hemantha Kulathilake
 
Addressing modes Breifly
Addressing modes BreiflyAddressing modes Breifly
Addressing modes Breifly
Tahir Jalali
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
nicky_walters
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
Infinity Tech Solutions
 
Computer
ComputerComputer
Computer
Hanaa Ahmed
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
DataminingTools Inc
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data Types
Dr Rajiv Srivastava
 

What's hot (16)

TextBox and RichTextBox in VB.Net
TextBox and RichTextBox in VB.NetTextBox and RichTextBox in VB.Net
TextBox and RichTextBox in VB.Net
 
Effective Java - Always override toString() method
Effective Java - Always override toString() methodEffective Java - Always override toString() method
Effective Java - Always override toString() method
 
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
Ultra-efficient algorithms for testing well-parenthesised expressions by Tati...
 
Error Detection N Correction
Error Detection N CorrectionError Detection N Correction
Error Detection N Correction
 
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit ModelSingle-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
Single-Bit Parity Detection and Correction using Hamming Code 7-Bit Model
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
..Ans 1
..Ans 1..Ans 1
..Ans 1
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
 
COM1407: Variables and Data Types
COM1407: Variables and Data Types COM1407: Variables and Data Types
COM1407: Variables and Data Types
 
Addressing modes Breifly
Addressing modes BreiflyAddressing modes Breifly
Addressing modes Breifly
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
Strings in c language
Strings in  c languageStrings in  c language
Strings in c language
 
Computer
ComputerComputer
Computer
 
LISP: Scope and extent in lisp
LISP: Scope and extent in lispLISP: Scope and extent in lisp
LISP: Scope and extent in lisp
 
Data Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data TypesData Communication & Computer Networks : Data Types
Data Communication & Computer Networks : Data Types
 

Viewers also liked

Building Your Online Following
Building Your Online FollowingBuilding Your Online Following
Building Your Online Following
Jason Crouch
 
Innovative Lesson Template
Innovative Lesson Template Innovative Lesson Template
Innovative Lesson Template
Arun Murali
 
Turning employees into ambassadors in social media
Turning employees into ambassadors in social mediaTurning employees into ambassadors in social media
Turning employees into ambassadors in social media
Okimo Clinic
 
Socap 1
Socap 1Socap 1
Socap 1
Duy Vọng
 
P.p jorge
P.p  jorgeP.p  jorge
P.p jorge
fernam16
 
Evasesión31 32
Evasesión31 32Evasesión31 32
Evasesión31 32
keithlerma
 
Investigación sobre la realidad escolar
Investigación sobre la realidad escolarInvestigación sobre la realidad escolar
Investigación sobre la realidad escolar
LoRy GoMez
 
Professional Development classes
Professional Development classesProfessional Development classes
Professional Development classes
JoLynn Rodabaugh
 
Lo importante que es el realizar tus planeaciones
Lo importante que es el realizar tus planeacionesLo importante que es el realizar tus planeaciones
Lo importante que es el realizar tus planeaciones
LoRy GoMez
 
Pointer
PointerPointer
Pointer
Phi Tường
 
Dia de muertos
Dia de muertosDia de muertos
Dia de muertos
Ivonne Monsalve
 
Презентация
ПрезентацияПрезентация
Презентация
wolodka2
 
9 Things to Look for in an Agency Management System
9 Things to Look for in an Agency Management System9 Things to Look for in an Agency Management System
9 Things to Look for in an Agency Management System
Strategic Insurance Software
 
Lap trinh-huong-doi-tuong-bang-c#
Lap trinh-huong-doi-tuong-bang-c#Lap trinh-huong-doi-tuong-bang-c#
Lap trinh-huong-doi-tuong-bang-c#
Thanhlanh nguyen
 
Làm phim không khó
Làm phim không khóLàm phim không khó
Làm phim không khó
nhanai ho
 
Exposicion (1)
Exposicion (1)Exposicion (1)
Exposicion (1)
chicapili
 

Viewers also liked (16)

Building Your Online Following
Building Your Online FollowingBuilding Your Online Following
Building Your Online Following
 
Innovative Lesson Template
Innovative Lesson Template Innovative Lesson Template
Innovative Lesson Template
 
Turning employees into ambassadors in social media
Turning employees into ambassadors in social mediaTurning employees into ambassadors in social media
Turning employees into ambassadors in social media
 
Socap 1
Socap 1Socap 1
Socap 1
 
P.p jorge
P.p  jorgeP.p  jorge
P.p jorge
 
Evasesión31 32
Evasesión31 32Evasesión31 32
Evasesión31 32
 
Investigación sobre la realidad escolar
Investigación sobre la realidad escolarInvestigación sobre la realidad escolar
Investigación sobre la realidad escolar
 
Professional Development classes
Professional Development classesProfessional Development classes
Professional Development classes
 
Lo importante que es el realizar tus planeaciones
Lo importante que es el realizar tus planeacionesLo importante que es el realizar tus planeaciones
Lo importante que es el realizar tus planeaciones
 
Pointer
PointerPointer
Pointer
 
Dia de muertos
Dia de muertosDia de muertos
Dia de muertos
 
Презентация
ПрезентацияПрезентация
Презентация
 
9 Things to Look for in an Agency Management System
9 Things to Look for in an Agency Management System9 Things to Look for in an Agency Management System
9 Things to Look for in an Agency Management System
 
Lap trinh-huong-doi-tuong-bang-c#
Lap trinh-huong-doi-tuong-bang-c#Lap trinh-huong-doi-tuong-bang-c#
Lap trinh-huong-doi-tuong-bang-c#
 
Làm phim không khó
Làm phim không khóLàm phim không khó
Làm phim không khó
 
Exposicion (1)
Exposicion (1)Exposicion (1)
Exposicion (1)
 

Similar to Chapter 03

Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
cmontanez
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
DivyaR219113
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
Terry Yoast
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCA
Raj vardhan
 
C++ programming
C++ programmingC++ programming
C++ programming
Anshul Mahale
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
Vijayananda Mohire
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptxLesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1
Ali Raza Jilani
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
Linda Bodrie
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
Abha Damani
 
Data type
Data typeData type
Data type
Isha Aggarwal
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
Radhakrishnan Chinnusamy
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
SowmyaJyothi3
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
Shashwat Shriparv
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
guest58c84c
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
jahanullah
 
Data types.pdf
Data types.pdfData types.pdf
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & Strings
Abhinav Porwal
 
Unit - 1.ppt
Unit - 1.pptUnit - 1.ppt

Similar to Chapter 03 (20)

Variables and calculations_chpt_4
Variables and calculations_chpt_4Variables and calculations_chpt_4
Variables and calculations_chpt_4
 
Visual Basic Fundamentals
Visual Basic FundamentalsVisual Basic Fundamentals
Visual Basic Fundamentals
 
Chapter 03
Chapter 03Chapter 03
Chapter 03
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
UNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCAUNIT-II VISUAL BASIC.NET | BCA
UNIT-II VISUAL BASIC.NET | BCA
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C Programming Assignment
C Programming AssignmentC Programming Assignment
C Programming Assignment
 
Lesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptxLesson 4 Basic Programming Constructs.pptx
Lesson 4 Basic Programming Constructs.pptx
 
C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1C++ Basics introduction to typecasting Webinar Slides 1
C++ Basics introduction to typecasting Webinar Slides 1
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
Unit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programmingUnit 1 introduction to visual basic programming
Unit 1 introduction to visual basic programming
 
Data type
Data typeData type
Data type
 
Chapter 6 Intermediate Code Generation
Chapter 6   Intermediate Code GenerationChapter 6   Intermediate Code Generation
Chapter 6 Intermediate Code Generation
 
Constants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya JyothiConstants Variables Datatypes by Mrs. Sowmya Jyothi
Constants Variables Datatypes by Mrs. Sowmya Jyothi
 
Intermediate code generation1
Intermediate code generation1Intermediate code generation1
Intermediate code generation1
 
C Sharp Nagina (1)
C Sharp Nagina (1)C Sharp Nagina (1)
C Sharp Nagina (1)
 
C Sharp Jn (1)
C Sharp Jn (1)C Sharp Jn (1)
C Sharp Jn (1)
 
Data types.pdf
Data types.pdfData types.pdf
Data types.pdf
 
Numeric Data Types & Strings
Numeric Data Types & StringsNumeric Data Types & Strings
Numeric Data Types & Strings
 
Unit - 1.ppt
Unit - 1.pptUnit - 1.ppt
Unit - 1.ppt
 

Recently uploaded

How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 

Recently uploaded (20)

How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 

Chapter 03

  • 2. Objective  The student will be able to:  What is Variable, constant  Know how to declare variable and Constant  Rule of naming variable and Constant  Using Data type  Scope of Variable and Constant  Converting data output  Format output  Develop small project using calculator Prepared by: Mr Pork Naron
  • 3. Variable  Provide a means to store data values that are not stored in files.  Support the computation of values through their use in formulas in assignment  Represent locations in a computer's memory  are assigned a unique name for reference when writing computer code statements. Prepared by: Mr Pork Naron
  • 4. DataType Prepared by: Mr Pork Naron DataType Description Bytes Text Data String Alphanumeric data such as letters of the alphabet Size varies Char Stores single Unicode characters (supports any international language). 2 Numeric Data Decimal often used to store dollars/cents 16 Double Double-precision numeric values with 14 digits of accuracy 8 Single Single-precision numeric values with 6 digits of accuracy 4 Short numeric values in the range -32,768 to 32,767 2 Integer numeric values in the range -2,147,483,648 to +2,147,483,647 4 Long numeric values that are very, very large 8
  • 5. DataType(Cont) Prepared by: Mr Pork Naron DataType Description Bytes Special DataType Boolean True or False 2 Byte Stores binary data of values 0 to 255 – can be used to store ASCIIcharacter code values 1 Date Stores dates in the form 1/1/0001 to 12/31/9999 8 Object Any type of data 4
  • 6. Naming Rules for Variable and Constant Prepared by: Mr Pork Naron  Can be letters, digits, and the underscore, but must begin with a letter  cannot contain spaces or periods  cannot be VB reserved words such as LET, PRINT, DIM, or CONST  are not case sensitive. This means that TotalInteger, TOTALINTEGER, and totalinteger are all equivalent names
  • 7. Naming Convention Prepared by: Mr Pork Naron  Create meaningful names  Avoid using abbreviations  Begin each name with an uppercase letter and capitalize each successive word in the name.  Use mixed case (such as AmountDueDecimal) for variables – use Uppercase for constant names (such as TAX_RATE_SINGLE)
  • 8. Declaring Variable & Constant Prepared by: Mr Pork Naron Variable  Dim  Eg: Dim EmployeeName as String Constant  Const  Eg: Const Age as Integer=23
  • 9. Scope of Variables and Constants Prepared by: Mr Pork Naron  Namespace : Public Shared(visible in whole project)  Module level: Private(variable), Const ( constant) – visile any procedure in specific form.  Local : Dim(variable), Const (constant) visible in only one procedure  Block : Dim(variable), Const(constant) – visible in only a portion of procedure
  • 10. Converting Input Data Types Prepared by: Mr Pork Naron  Text property – always stores string values, even if the string looks like a number.  Parse method – converts a value from a Text property to an equivalent numeric value or other types
  • 11. Converting Variable Values to Output Data Types Prepared by: Mr Pork Naron  Use (.ToString) method to convert variable value to output data  TxtOutput.text = Output.ToString()
  • 12. Arithmetic Operators Prepared by: Mr Pork Naron  + Addition  - Subtraction  * Multiplication  / Division  ^ Exponentiation  Integer Division  Mod Modulus Division
  • 13. Order of Precedence Prepared by: Mr Pork Naron 1. Values enclosed inside parentheses (xxxx) 2. Exponentiation ^ 3. Multiplication and Division(*,/) 4. Addition and Subtraction (+, -)
  • 14. Order of Precedence(cont) Prepared by: Mr Pork Naron Eg: Assume that: X=2, Y=4, and Z=3
  • 15. Order of Precedence(cont) Prepared by: Mr Pork Naron • mathematical notation and the equivalent VB expression
  • 16. Format Function Prepared by: Mr Pork Naron  FormatCurrency  BalanceDueTextBox.Text = FormatCurrency(BalanceDueDecimal)  FormatNumber  AmountTextBox.Text = FormatNumber(AmountDouble)  FormatPercent  PercentFinishedTextBox.Text = FormatPercent(FinishedSingle)  FormatDate  DateTextBox.Text = FormatDateTime(StartDate, DateFormat.ShortDate)  DateTextBox.Text = FormatDateTime(StartDate, DateFormat.LongDate)  TimeTextBox.Text = FormatDateTime(StartDateTime, DateFormat.ShortTime)  TimeTextBox.Text = FormatDateTime(StartDateTime, DateFormat.LongTime)
  • 17. Compute Lab Prepared by: Mr Pork Naron Develop Small Calculator

Editor's Notes

  1. Create meaningful names – do not name a variable or constant X or Y or XInteger. Instead use names such as StudentNameString, CountStudentsInteger, and AmountDueDecimal. 2. Avoid using abbreviations unless the abbreviation is standard and well-accepted such as SSNString for storing social security number values. 3. Begin each name with an uppercase letter and capitalize each successive word in the name. 4. Use mixed case (such as AmountDueDecimal) for variables – use Uppercase for constant names (such as TAX_RATE_SINGLE).
  2. As part of the Input phase of the Input-Process-Output model, you must convert values from the Text property of a TextBox and store the converted values to memory variables. Text property – always stores string values, even if the string looks like a number. Parse method – converts a value from a Text property to an equivalent numeric value for storage to a numeric variable. Parse means to examine a string character by character and convert the value to another format such as decimal or integer.. In order to parse a string that contains special characters such as a decimal point, comma, or currency symbol, use the Globalization enumeration shown in the coding examples below. § If you don’t specify the Globalization value of Globalization.NumberStyles.Currency, then a value entered into a textbox controlsuch as $1,515.95 will NOT parse to Decimal. The Globalization value Globalization.NumberStyles.Number will allow the Integer.Parse method to parse a textbox value that contains a comma, such as 1,249. VB's Intellisense will display the various possible values for the Globalization enumeration. Example #1 – this example shows you how to declare numeric variables then store values to them from Textbox controls. -----------------Declare variables------------------ Dim PriceDecimal As Decimal Dim QuantityInteger As Integer ---------------Convert values from textbox controls to memory PriceDecimal = Decimal.Parse(PriceTextBox.Text,Globalization.NumberStyles.Currency) QuantityInteger = Integer.Parse(QuantityTextBox.Text,Globalization.NumberStyles.Number) Example #2 – this example shows you how to declare numeric variables and store values to them from Textbox controls using a single assignment statement in one step. ----------------------Declare variables and convert values from textbox controls to memory in a single statement Dim PriceDecimal As Decimal = Decimal.Parse(PriceTextBox.Text, Globalization.NumberStyles.Currency) Dim QuantityInteger As Integer = Integer.Parse(QuantityTextBox.Text, Globalization.NumberStyles.Number) Older versions of VB used named functions to convert values. Examples are the CDec (convert to Decimal) and CInt (convert to Integer) functions shown here – you may encounter these functions in other VB books that you read or in the VB Help files. There are some advantages to these named functions: · A TextBox Text property value of $100.00 will NOT generate an error if you use the CDec function to convert the value as shown below—the data will convert satisfactorily. · The functions are faster and easier to type. 'Converts to decimal and Integer 3-Variables, Constants, and Calculations http://www.siue.edu/~dbock/cmis142/WebNotes/Ch3Notes/3-variables.htm 9 of 30 3/27/2014 3:26 PM PriceDecimal = CDec(PriceTextBox.Text) QuantityInteger = CInt(QuantityTextBox.Text)
  3. In order to display numeric variable values as output the values must be converted from numeric data types to string in order to store the data to the Text property of a TextBox control. Use the ToString method. These examples show converting strings to a numeric representation with 2 digits to the right of the decimal (N2) and currency with 2 digits to the right of the decimal (C2) as well as no digits to the right of a number (N0 – that is N zero, not N Oh).
  4. In order to display numeric variable values as output the values must be converted from numeric data types to string in order to store the data to the Text property of a TextBox control. Use the ToString method. These examples show converting strings to a numeric representation with 2 digits to the right of the decimal (N2) and currency with 2 digits to the right of the decimal (C2) as well as no digits to the right of a number (N0 – that is N zero, not N Oh).
  5. The order of precedence for expressions that have more than one operation is the same as for other programming languages. The order of precedence is applied to an expression by evaluating the expression from left to right for values within parentheses – within parentheses VB will process the expression from left to right looking for an applying the exponentiation operator, then again from left to right applying the multiplication and division operators, etc. This left to right application of operators continues in pass-after-pass working down the order of precedence. Use parentheses to control the application of the order of precedence of operations. · Example #1: (5 + 6) * 2 is evaluated: first as 5 + 6 = 11, because the parentheses force the addition operation to be evaluated before the multiplication operation, or next VB will multiple 11 by 2 to arrive at 22. · Example #2: 5 + 6 * 2 is evaluated: first as 6 * 2 = 12, because the multiplication operator is higher in the order of precedence, o next VB will add 5 to 12 to arrive at 17.
  6. The order of precedence for expressions that have more than one operation is the same as for other programming languages. The order of precedence is applied to an expression by evaluating the expression from left to right for values within parentheses – within parentheses VB will process the expression from left to right looking for an applying the exponentiation operator, then again from left to right applying the multiplication and division operators, etc. This left to right application of operators continues in pass-after-pass working down the order of precedence. Use parentheses to control the application of the order of precedence of operations. · Example #1: (5 + 6) * 2 is evaluated: first as 5 + 6 = 11, because the parentheses force the addition operation to be evaluated before the multiplication operation, or next VB will multiple 11 by 2 to arrive at 22. · Example #2: 5 + 6 * 2 is evaluated: first as 6 * 2 = 12, because the multiplication operator is higher in the order of precedence, o next VB will add 5 to 12 to arrive at 17.
  7. The order of precedence for expressions that have more than one operation is the same as for other programming languages. The order of precedence is applied to an expression by evaluating the expression from left to right for values within parentheses – within parentheses VB will process the expression from left to right looking for an applying the exponentiation operator, then again from left to right applying the multiplication and division operators, etc. This left to right application of operators continues in pass-after-pass working down the order of precedence. Use parentheses to control the application of the order of precedence of operations. · Example #1: (5 + 6) * 2 is evaluated: first as 5 + 6 = 11, because the parentheses force the addition operation to be evaluated before the multiplication operation, or next VB will multiple 11 by 2 to arrive at 22. · Example #2: 5 + 6 * 2 is evaluated: first as 6 * 2 = 12, because the multiplication operator is higher in the order of precedence, o next VB will add 5 to 12 to arrive at 17.