SlideShare a Scribd company logo
1 of 23
Input - Process - Output

       in VB.NET




                           1
Objectives
Distinguish between logic and syntax
Understand and use the input statement
Understand and use the assignment
statement
Understand and use the output statement
Understand and use arithmetic operators
with precedence
Successfully write program solutions that
require input, processing, and output
                                            2
Logic and Syntax
A computer program is a solution to a
problem.
An algorithm is the logical design used to
accomplish a specific objective.
Syntax refers to the specific rules of a
programming language.



                                             3
Input Statements




                   4
Input Statements
An input statement accepts data from the
user and stores that data into a variable.
A variable is a storage location that can be
accessed and changed by developer code.
A variable has a name and an associated
data value.
A variable has a data type that determines
the kind of data values the variable can
store.

                                               5
Declaring Variables
Variables are declared with the Dim
statement (short for Dimension statement).
One or more variables can be declared with
a single Dim statement.
The Dim statement can be used to specify
the variable’s initial value by placing an
equal sign after the data type.


                                             6
Naming Rules for Variables
 A variable must have a unique name, called
 an identifier.
 Identifiers must follow three rules:
   Begin with a letter or underscore
   Contain only letters, digits, and underscores
   Cannot be reserved words

Dim identifier [, identifier] [As datatype [= initialvalue]]


                                                               7
Working with Constants
A constant is a storage location whose
value cannot change during the execution
of the program.
Constants are declared with the Const
declaration.
      Const identifier As datatype = value




                                             8
Data Type
Data Type           Description
String              Text
Byte (1 byte)       Positive Whole Number (0 to 255)
Short (2 bytes)     Whole Number (-32,768 to 32,767)
Integer (4 bytes)   Whole Number (+ or – up to 2 million)
Long (8 bytes)      Whole Number (huge!)
Single (4 bytes)    Floating point (+ or – up to 3.4 x 1038)
Double (8 bytes)    Floating point (+ or – up to 1.8 x 10308)
Decimal             Stored exactly as BCD (currency & percentages)
Date                Also stores time
Boolean             True or false
Char                Single character or positive number (up to 65535)


                                                                        9
Weekly Paycheck Program
The weekly
paycheck program
has two input
variables:
Hours and Rate




                          10
Operators and Expressions
An operator is a symbol that indicates an
action to be performed.
Value-returning code elements such as
variables, constants, and expressions can be
combined with one or more operators to
form an expression.



                                               11
Assignment Statements
The assignment
statement can be used
to perform a
calculation and store
the result.
An expression is a
value-returning code
element, such as a
variable or
mathematical formula.

                            12
The Assignment Statement
An assignment statement is used to store a
value into a variable or an object property.
 variable = expression
 object.property = expression
The equal sign (=) is the assignment
operator.


                                               13
Numbers and String Operators

  Arithmetic operators require numeric
  operands and produce numeric results.
  The string operator concatenation (&)
  requires String operands and produces a
  String result such as:
   S = “sun” & “set”
   S becomes “sunset”


                                            14
Numerical Operators
Operation    Operator      Expression 1   Result 1   Expression 2   Result 2

Plus &
               +       –     4–5+2           1        4 – (5 + 2)      -3
Minus
Multiply &
               * /           1+3*7           22         17 / 3        5.667
Divide
Integer
                             12  4         3          17  3          5
Division
Integer
               Mod           12 Mod 4        0         17 Mod 3         2
Remainder
Exponent
                   ^         5^2+1           26       5 ^ (2 + 1)      125
(Power of)


                                                                               15
How to Write Formulas




                        16
Output Statements
   (flow chart)




                    17
Intrinsic Functions
VB .NET provides a large number of
intrinsic functions to improve developer
productivity.
Intrinsic functions support a broad range of
activities, including math calculations,
business calculations, time and date
functions, string formatting functions, and
many more.

                                               18
Common Functions
        Intrinsic functions are predefined commands that
        provide developers with common functions.
Function             Example 1          Result 1         Example 2         Result 2

Val()                  (“23.5”)           23.5             (“£32”)            0

IsNumeric()            (“23.5”)           True             (“£32”)           True

FormatCurrency()     (1234.567)        £1,234.57            (4.5)           £4.50

Format(expr,str)     (1/2, “0.##”)        “0.5”        (6.666, “0.###”)     “6.67”

Int()                    (3.8)             3             Int(Rnd())           0

                                      Double value                          Integer
Rnd()                     ()                           Int(Rnd()*6)+1
                                     between 0 and 1                      from 1 to 6
Abs()
                        (-3.3)             3.3              (5.67)           5.67
Import System.Math
                                                                                        19
Rnd Statement
The Rnd statement generates a single
precision random value between 0.0 up
to (but not including) 1.0.
The Randomize statement is used to
change the seed value (random
sequence).



                                        20
Financial Functions
Pmt is a function for determining monthly
payments.
 Pmt(Rate, NPer, PV)
FV is a function for determining the future
value of an annuity based on periodic, fixed
payments and a fixed interest rate.
 FV(Rate, NPer, Pmt)


                                               21
Summary
Variables are storage locations used for holding input
and processing information.
 Each variable has two components: its name and its value.
 It is good practice to make variable names descriptive with
  mixed case.
 The Dim statement is used to declare a variable by
  specifying its name and data type.
Input statements are used to get data into variables.
Assignment statements are used to perform
calculations and store the result.


                                                                22
Summary
Expressions are combinations of operators and
value-returning code elements such as variables,
constants, and literals.
 One of the common uses of an expression is to perform
  a calculation for an assignment statement.
 Intrinsic functions provide pre-defined methods for
  common processing requirements.
Output statements are used to display
information.
Input, assignment, and output statements are
sufficient to write small programs.

                                                          23

More Related Content

What's hot

Ai_Project_report
Ai_Project_reportAi_Project_report
Ai_Project_reportRavi Gupta
 
Programming in Scala - Lecture Two
Programming in Scala - Lecture TwoProgramming in Scala - Lecture Two
Programming in Scala - Lecture TwoAngelo Corsaro
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture ThreeAngelo Corsaro
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Sheik Uduman Ali
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5Infinity Tech Solutions
 
Universal Portfolios Generated by Reciprocal Functions of Price Relatives
Universal Portfolios Generated by Reciprocal Functions of Price RelativesUniversal Portfolios Generated by Reciprocal Functions of Price Relatives
Universal Portfolios Generated by Reciprocal Functions of Price Relativesiosrjce
 
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)Tech Triveni
 
Data structures using C
Data structures using CData structures using C
Data structures using CPdr Patnaik
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2Abdul Khan
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed worldDebasish Ghosh
 
Mining Functional Patterns
Mining Functional PatternsMining Functional Patterns
Mining Functional PatternsDebasish Ghosh
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++Ilio Catallo
 
Functional and Algebraic Domain Modeling
Functional and Algebraic Domain ModelingFunctional and Algebraic Domain Modeling
Functional and Algebraic Domain ModelingDebasish Ghosh
 

What's hot (20)

Ai_Project_report
Ai_Project_reportAi_Project_report
Ai_Project_report
 
Programming in Scala - Lecture Two
Programming in Scala - Lecture TwoProgramming in Scala - Lecture Two
Programming in Scala - Lecture Two
 
Programming in Scala - Lecture Three
Programming in Scala - Lecture ThreeProgramming in Scala - Lecture Three
Programming in Scala - Lecture Three
 
Array
ArrayArray
Array
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0Let Us Learn Lambda Using C# 3.0
Let Us Learn Lambda Using C# 3.0
 
arrays
arraysarrays
arrays
 
Database Management System-session 3-4-5
Database Management System-session 3-4-5Database Management System-session 3-4-5
Database Management System-session 3-4-5
 
Universal Portfolios Generated by Reciprocal Functions of Price Relatives
Universal Portfolios Generated by Reciprocal Functions of Price RelativesUniversal Portfolios Generated by Reciprocal Functions of Price Relatives
Universal Portfolios Generated by Reciprocal Functions of Price Relatives
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
Network Security CS3-4
Network Security CS3-4 Network Security CS3-4
Network Security CS3-4
 
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)
Becoming a Functional Programmer - Harit Himanshu (Nomis Solutions)
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Computer Programming- Lecture 6
Computer Programming- Lecture 6Computer Programming- Lecture 6
Computer Programming- Lecture 6
 
Algorithm & data structure lec2
Algorithm & data structure lec2Algorithm & data structure lec2
Algorithm & data structure lec2
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 
Mining Functional Patterns
Mining Functional PatternsMining Functional Patterns
Mining Functional Patterns
 
Resource wrappers in C++
Resource wrappers in C++Resource wrappers in C++
Resource wrappers in C++
 
Cs501 rel algebra
Cs501 rel algebraCs501 rel algebra
Cs501 rel algebra
 
Functional and Algebraic Domain Modeling
Functional and Algebraic Domain ModelingFunctional and Algebraic Domain Modeling
Functional and Algebraic Domain Modeling
 

Similar to IPIO - Input, Process, Output in VB.NET

introductory concepts
introductory conceptsintroductory concepts
introductory conceptsWalepak Ubi
 
chapter-2.ppt
chapter-2.pptchapter-2.ppt
chapter-2.pptXanGwaps
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoJoel Falcou
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented TechnologiesUmesh Nikam
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Jitendra Bafna
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2Don Dooley
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constantsCtOlaf
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++Manzoor ALam
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]ecko_disasterz
 
Deep Dive Into Catalyst: Apache Spark 2.0'S Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0'S OptimizerDeep Dive Into Catalyst: Apache Spark 2.0'S Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0'S OptimizerSpark Summit
 

Similar to IPIO - Input, Process, Output in VB.NET (20)

introductory concepts
introductory conceptsintroductory concepts
introductory concepts
 
chapter-2.ppt
chapter-2.pptchapter-2.ppt
chapter-2.ppt
 
Designing Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.ProtoDesigning Architecture-aware Library using Boost.Proto
Designing Architecture-aware Library using Boost.Proto
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
C programming part2
C programming part2C programming part2
C programming part2
 
Object Oriented Technologies
Object Oriented TechnologiesObject Oriented Technologies
Object Oriented Technologies
 
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
Engineering Student MuleSoft Meetup#6 - Basic Understanding of DataWeave With...
 
Unit i intro-operators
Unit   i intro-operatorsUnit   i intro-operators
Unit i intro-operators
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
additional.pptx
additional.pptxadditional.pptx
additional.pptx
 
Operators
OperatorsOperators
Operators
 
2 EPT 162 Lecture 2
2 EPT 162 Lecture 22 EPT 162 Lecture 2
2 EPT 162 Lecture 2
 
C Programming - Refresher - Part III
C Programming - Refresher - Part IIIC Programming - Refresher - Part III
C Programming - Refresher - Part III
 
5. using variables, data, expressions and constants
5. using variables, data, expressions and constants5. using variables, data, expressions and constants
5. using variables, data, expressions and constants
 
02 functions, variables, basic input and output of c++
02   functions, variables, basic input and output of c++02   functions, variables, basic input and output of c++
02 functions, variables, basic input and output of c++
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
 
Python
PythonPython
Python
 
Deep Dive Into Catalyst: Apache Spark 2.0'S Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0'S OptimizerDeep Dive Into Catalyst: Apache Spark 2.0'S Optimizer
Deep Dive Into Catalyst: Apache Spark 2.0'S Optimizer
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 

More from nicky_walters (20)

Design documentation
Design documentationDesign documentation
Design documentation
 
Pseudocode flowcharts
Pseudocode flowchartsPseudocode flowcharts
Pseudocode flowcharts
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Software development lifecycle
Software development lifecycleSoftware development lifecycle
Software development lifecycle
 
Data structures vb
Data structures vbData structures vb
Data structures vb
 
Design for edp
Design for edpDesign for edp
Design for edp
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Data types vbnet
Data types vbnetData types vbnet
Data types vbnet
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Ndu06 typesof language
Ndu06 typesof languageNdu06 typesof language
Ndu06 typesof language
 
Event driventheory
Event driventheoryEvent driventheory
Event driventheory
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Simple debugging
Simple debuggingSimple debugging
Simple debugging
 
Debugging
DebuggingDebugging
Debugging
 
Using loops
Using loopsUsing loops
Using loops
 
Decisions
DecisionsDecisions
Decisions
 
Decisions
DecisionsDecisions
Decisions
 
Controls
ControlsControls
Controls
 
Decisions
DecisionsDecisions
Decisions
 

IPIO - Input, Process, Output in VB.NET

  • 1. Input - Process - Output in VB.NET 1
  • 2. Objectives Distinguish between logic and syntax Understand and use the input statement Understand and use the assignment statement Understand and use the output statement Understand and use arithmetic operators with precedence Successfully write program solutions that require input, processing, and output 2
  • 3. Logic and Syntax A computer program is a solution to a problem. An algorithm is the logical design used to accomplish a specific objective. Syntax refers to the specific rules of a programming language. 3
  • 5. Input Statements An input statement accepts data from the user and stores that data into a variable. A variable is a storage location that can be accessed and changed by developer code. A variable has a name and an associated data value. A variable has a data type that determines the kind of data values the variable can store. 5
  • 6. Declaring Variables Variables are declared with the Dim statement (short for Dimension statement). One or more variables can be declared with a single Dim statement. The Dim statement can be used to specify the variable’s initial value by placing an equal sign after the data type. 6
  • 7. Naming Rules for Variables A variable must have a unique name, called an identifier. Identifiers must follow three rules:  Begin with a letter or underscore  Contain only letters, digits, and underscores  Cannot be reserved words Dim identifier [, identifier] [As datatype [= initialvalue]] 7
  • 8. Working with Constants A constant is a storage location whose value cannot change during the execution of the program. Constants are declared with the Const declaration. Const identifier As datatype = value 8
  • 9. Data Type Data Type Description String Text Byte (1 byte) Positive Whole Number (0 to 255) Short (2 bytes) Whole Number (-32,768 to 32,767) Integer (4 bytes) Whole Number (+ or – up to 2 million) Long (8 bytes) Whole Number (huge!) Single (4 bytes) Floating point (+ or – up to 3.4 x 1038) Double (8 bytes) Floating point (+ or – up to 1.8 x 10308) Decimal Stored exactly as BCD (currency & percentages) Date Also stores time Boolean True or false Char Single character or positive number (up to 65535) 9
  • 10. Weekly Paycheck Program The weekly paycheck program has two input variables: Hours and Rate 10
  • 11. Operators and Expressions An operator is a symbol that indicates an action to be performed. Value-returning code elements such as variables, constants, and expressions can be combined with one or more operators to form an expression. 11
  • 12. Assignment Statements The assignment statement can be used to perform a calculation and store the result. An expression is a value-returning code element, such as a variable or mathematical formula. 12
  • 13. The Assignment Statement An assignment statement is used to store a value into a variable or an object property.  variable = expression  object.property = expression The equal sign (=) is the assignment operator. 13
  • 14. Numbers and String Operators Arithmetic operators require numeric operands and produce numeric results. The string operator concatenation (&) requires String operands and produces a String result such as:  S = “sun” & “set”  S becomes “sunset” 14
  • 15. Numerical Operators Operation Operator Expression 1 Result 1 Expression 2 Result 2 Plus & + – 4–5+2 1 4 – (5 + 2) -3 Minus Multiply & * / 1+3*7 22 17 / 3 5.667 Divide Integer 12 4 3 17 3 5 Division Integer Mod 12 Mod 4 0 17 Mod 3 2 Remainder Exponent ^ 5^2+1 26 5 ^ (2 + 1) 125 (Power of) 15
  • 16. How to Write Formulas 16
  • 17. Output Statements (flow chart) 17
  • 18. Intrinsic Functions VB .NET provides a large number of intrinsic functions to improve developer productivity. Intrinsic functions support a broad range of activities, including math calculations, business calculations, time and date functions, string formatting functions, and many more. 18
  • 19. Common Functions Intrinsic functions are predefined commands that provide developers with common functions. Function Example 1 Result 1 Example 2 Result 2 Val() (“23.5”) 23.5 (“£32”) 0 IsNumeric() (“23.5”) True (“£32”) True FormatCurrency() (1234.567) £1,234.57 (4.5) £4.50 Format(expr,str) (1/2, “0.##”) “0.5” (6.666, “0.###”) “6.67” Int() (3.8) 3 Int(Rnd()) 0 Double value Integer Rnd() () Int(Rnd()*6)+1 between 0 and 1 from 1 to 6 Abs() (-3.3) 3.3 (5.67) 5.67 Import System.Math 19
  • 20. Rnd Statement The Rnd statement generates a single precision random value between 0.0 up to (but not including) 1.0. The Randomize statement is used to change the seed value (random sequence). 20
  • 21. Financial Functions Pmt is a function for determining monthly payments.  Pmt(Rate, NPer, PV) FV is a function for determining the future value of an annuity based on periodic, fixed payments and a fixed interest rate.  FV(Rate, NPer, Pmt) 21
  • 22. Summary Variables are storage locations used for holding input and processing information.  Each variable has two components: its name and its value.  It is good practice to make variable names descriptive with mixed case.  The Dim statement is used to declare a variable by specifying its name and data type. Input statements are used to get data into variables. Assignment statements are used to perform calculations and store the result. 22
  • 23. Summary Expressions are combinations of operators and value-returning code elements such as variables, constants, and literals.  One of the common uses of an expression is to perform a calculation for an assignment statement.  Intrinsic functions provide pre-defined methods for common processing requirements. Output statements are used to display information. Input, assignment, and output statements are sufficient to write small programs. 23