Visual Basic.NET BASICS Lesson 4 Mathematical Operators.

Slides:



Advertisements
Similar presentations
Chapter 2: Designing Applications
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
1.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
Data types and variables
Chapter 2 Data Types, Declarations, and Displays
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
JavaScript, Third Edition
Clearly Visual Basic: Programming with Visual Basic 2008
Objectives You should be able to describe: Data Types
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and.
Variables and Constants
CS0004: Introduction to Programming Variables – Numbers.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
2440: 211 Interactive Web Programming Expressions & Operators.
CS0004: Introduction to Programming Variables – Strings.
Microsoft Visual Basic 2005 BASICS Lesson 4 Mathematical Operators.
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Input, Output, and Processing
Chapter 2: Using Data.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 5 Completing the Inventory Application Introducing Programming.
Introduction to Programming with RAPTOR
Mathematical Calculations in Java Mrs. G. Chapman.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations.
3 1 Sending Data Using an Online Form CGI/Perl Programming By Diane Zak.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Three Memory Locations and Calculations.
Chapter 4 Variables and constants. 4.1 Variables -Use of variables is good programming style -easier to modify -easier for a programmer to understand.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 9, 2005 Lecture Number: 6.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
Lesson 4 Mathematical Operators! October 6, 2009.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 3 – Introduction to C# Programming Outline 3.1 Introduction 3.2 Simple Program: Printing a Line.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
More Visual Basic!. Creating a Standalone Program A standalone program will allow you to make a program file that can be run like other Windows programs,
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Making Interactive Programs with Visual Basic .NET
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are used in programs so that values can be represented with.
© 2006 Lawrenceville Press Slide 1 Chapter 4 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration.
Slide 1 Chapter 3 Variables  A variable is a name for a value stored in memory.  Variables are created using a declaration statement. For example: Dim.
Lesson 4 Mathematical Operators! September 29, 2008 (Pages 62-65)
Topics Designing a Program Input, Processing, and Output
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
Introduction to Scripting
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Introduction to C++ Programming
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Microsoft Visual Basic 2005 BASICS
Topics Designing a Program Input, Processing, and Output
Presentation transcript:

Visual Basic.NET BASICS Lesson 4 Mathematical Operators

2 Objectives Describe the purpose of operators and how calculations are performed in Visual Basic.NET. Create label controls. Use the addition and assignment operators. Use text boxes to get data from the user and use the Val function to extract a numeric value from a text box.

3 Objectives (continued) Split code statements among the lines in the code window. Use the subtraction operator. Use unary minus. Use the multiplication and division operators with the Fix function to remove the fractional portion of numbers. Perform integer division and use the modulus operator.

4 Performing Calculations in Visual Basic.NET Like other programming languages, Visual Basic.NET allows you to use mathematical equations in your programs. Operators are symbols that perform specific operations in Visual Basic.NET statements. The symbols “*” and “/” are used to represent multiplication and division in Visual Basic.NET.

5 Creating Label Controls The Label control is used to place text in a form. Sometimes a label is used to identify a text box or to add a title or message to a form. Labels can also be used to provide output. To provide output, you write code for the desired calculation.

6 Using the Addition and Assignment Operators The addition operator (+) and the assignment operator (=) perform just as you would expect. The term hard-coded refers to information that is entered directly into the source code and cannot change while the program runs.

7 Using Text Boxes and the Val Function Text boxes are the fields placed on dialog boxes and in other windows that allow the user to enter a value. The Text property of a text box specifies what text will appear on the text box.

8 How Text Differs from Numeric Data In a computer, text – which can include letters, symbols, and numbers – is treated differently than strictly numeric information. Numbers in a text box must be converted to a true numeric value before they can be used in a calculation. Understand that the characters entered in text boxes need to be converted from text to a numerical value before mathematical operations can be performed.

9 Using the Val Function The conversion necessary to convert the numeric text characters in a text box to numeric values is done by the Val function. The Val function takes numbers that are in text format and returns a numeric value that can be used in calculations.

10 Splitting Code Statements among Lines Visual Basic.NET provides a way to split a line of code among two or more lines. Within a line of code, you can key the underscore, known as the line-continuation character. The line-continuation character tells the compiler to skip the next line and treat the text there as if it were a part of the same line.

11 Using the Subtraction Operator The subtraction operator subtracts the value to the right of the operator from the value to the left of the operator.

12 Using Unary Minus You can use the subtraction operator as unary minus to perform negation, which means making a positive value negative or making a negative value positive. The addition operator can be used as a unary plus.

13 Using Fix Most programming languages include a function that drops the fractional part of a number. This process is called truncation. In Visual Basic.NET, the Fix function returns a truncated whole number.

14 Performing Integer Division and Using the Modulus Operator In computer programming, there are times when you want to work exclusively with whole numbers called integers. For cases when you want to work strictly with integers, Visual Basic.NET provides two special operations: integer division and modulus.

15 Performing Integer Division Integer division returns only the whole number portion of the division of integers. Integer division is performed using the backslash (\).

16 Using the Modulus Operator Modulus returns the remainder of integer division. The modulus operator is (Mod).

17 Summary Visual Basic. NET allows you to use mathematical equations in your programs. Operators are symbols that perform specific operations in Visual Basic. NET statements. The addition operator (+) adds values. The assignment operator (=) assigns the result of the expression on the right of the operator to the item to the left of the operator.

18 Summary (continued) The subtraction operator (–) subtracts the value to the right of the operator from the value to the left of the operator. The subtraction operator can be used to perform negation. When used in this way, the subtraction operator is called the unary minus. Values keyed directly into Visual Basic. NET code are called hard-coded values or literals.

19 Summary (continued) Text boxes are the fields placed on dialog boxes and in other windows that allow the user to enter a value. The numbers in a text box are considered to be text characters. To use the numbers as actual values in a calculation, the Val function must be used to convert the numeric text to a numeric value.

20 Summary (continued) When a line of code is long, you can split the code into two lines in the Code window by keying an underscore at the end of the line and continuing the statement on the next line. The underscore is called the line- continuation character. Placing an apostrophe in code allows you to enter text (called a comment) into the code. Everything from the apostrophe to the end of the line will be ignored.

21 Summary (continued) Multiplication is represented by an asterisk (*). Division is represented by a forward slash (/). The Fix function removes the fractional portion of a number. The Fix function performs an operation called truncation. Integer division is represented by a backward slash (\). Integer division returns only the whole number portion of the division of integers. The modulus operator (Mod) returns the remainder of integer division.