Lesson 4 Mathematical Operators! October 6, 2009.

Slides:



Advertisements
Similar presentations
CPIT 102 CPIT 102 CHAPTER 1 COLLABORATING on DOCUMENTS.
Advertisements

Tutorial 8: Developing an Excel Application
Using Multiple Forms! Creating a Splash Screen. Uses of Multiple Forms Includes: Dialog Boxes (appear often in Windows Programs) Splash Screen (a window.
IMS1906 Programming in VB.NET Week 3 – Lecture 1 Application Development © Angela Carbone Monash University School of Information Management.
Clearly Visual Basic: Programming with Visual Basic 2008
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.
Access Lesson 2 Creating a Database
CS0004: Introduction to Programming Input and Output.
Chapter 3 Introducing Visual Basic.NET. 3.1 Visual Basic.NET Windows Programming -Used to create Windows, Web, and Console applications -Uses predefined.
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
06/10/ Working with Data. 206/10/2015 Learning Objectives Explain the circumstances when the following might be useful: Disabling buttons and.
Visual Basic 101.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Excel 2010 © 2011 The McGraw-Hill Companies,
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.
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Input, Output, and Processing
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
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.
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.
CS0004: Introduction to Programming Project 1 – Lessons Learned.
Data Types and Variables. Data Type! Computers are all about Data! Data can be in the form of Text Dates Sounds Pictures.
Real Numbers Review #1. The numbers 4, 5, and 6 are called elements. S = {4, 5, 6} When we want to treat a collection of similar but distinct objects.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
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 for Application - Microsoft Access 2003 Programming applications using Objects.
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.
 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.
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Variables and Expressions Programming Right from the Start with Visual Basic.NET 1/e 7.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Visual Basic A Quick Tutorial VB Review for ACS 367.
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,
Using Option Buttons. Option Buttons Are similar to checkboxes. Must appear in groups. Only one button in the group can be selected at a time. Sometimes.
Visual Basic 6 Programming Decide how many variables you need by looking at this form. There is one textbox for input and there are 3 labels for output,
Lesson 5 Exponentiation,Order of Operations and Error Handling.
21/03/ Working with Controls Text and List Boxes.
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.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Lesson 4 Mathematical Operators! September 29, 2008 (Pages 62-65)
A variable is a name for a value stored in memory.
Topics Designing a Program Input, Processing, and Output
Arithmetic operations and operators, converting data types and formatting programs for output. Year 11 Information Technology.
2.5 Another Java Application: Adding Integers
Variables and Arithmetic Operations
Data Validation and Protecting Workbook
Variables, Expressions, and IO
Developing an Excel Application
Introduction to Scripting
Variables and Arithmetic Operations
Microsoft Visual Basic 2005 BASICS
Please use speaker notes for additional information!
Chapter 3 – Introduction to C# Programming
Topics Designing a Program Input, Processing, and Output
Microsoft Visual Basic 2005 BASICS
Introduction to Programming
Topics Designing a Program Input, Processing, and Output
Introduction to Visual Basic 2010
Presentation transcript:

Lesson 4 Mathematical Operators! October 6, 2009

Today’s Agenda Looking at Vocabulary Words Working with Mathematical Operators Create a Simple Addition Program

Performing Calculations in Visual Basic Operators Are symbols that perform certain operations in Visual Basic Statements

Mathematical Operators OperatorDescription =Assignment +Addition -Subtraction *Multiplication / (Forward Slash) Division \ (Backward Slash) Integer division ModModulus

Purpose of Label Controls Label Control Is used to place text on a form Sometimes is used to identify a text box Sometimes is used to add a title Sometimes is used to add a message Cannot be changed by user Also can be used to provide output

Let’s create our example program! 1.Open Visual Basic. 2.Open New Standard EXE project. 3.In the properties window, give the new form the name frmAddition and the caption Addition. 4.Insert a label and click the Caption property. 5.Key in your name for the label. 6.Name your label lblMyName. 7.Save the project with the form named frmAddition and project name Addition.

1.Insert another label on the form. 2.Position it in the center of the form. 3.Change the caption of the label to the number zero (0). 4.Change the name of the new label to lblAnswer. 5.Insert a command button. 6.Name the command button cmdCalculate. 7.Change the button’s caption to Calculate. 8.Add code in code view window. lblAnswer.Caption = Close the code view window and run your program.

What happen? Who can explain?

Working with Mathematical Operators October 7, 2009

Note! Hard-coded values –The term hard-coded refers to information that is entered directly into the source code and cannot change while the program runs. –Example: lblAnswer.Caption =

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.

Text –vs-Numeric Data Text Boxes Accept data from the user. Comes in the form of text. Includes letters, symbols, and numbers. Numeric Data Numbers in a text box must be converted to a true numeric value before they can be used in a calculation. The conversion used to convert to numbers is the Val Function!

The Val Function Takes numbers that are in a text format and returns numeric value that can be used in calculations. Example: lblTotal.caption = Val(txtPrice.Text) + Val(txtSalesTax.Text)

Splitting Code Statements Among Lines When splitting a line of code among two or more lines use a underscore (_)! Example: lblTotal.caption = Val(txtPrice.Text)+_ Val(txtSalesTax.Text) The underscore is called line-continuation character and it tells the compiler to skip to the next line and treat the text there as if it were part of the same line.

Comments! The apostrophe ( ‘ ) at the beginning of the code tells the compiler to ignore everything that follows. Example: ‘ Calculate total expenses.

Fix Function There are times when you are interested in only whole numbers after a calucation is performed. Use the Fix Function! –Drops the fractional part of a number. –In other words, it removes everything to the right of the decimal point which is called truncation. –Returns the truncated whole number.

Homework Make sure you pick up the Homework worksheet before you leave!

Performing Integer Division using Mod! October 8, 2009

Open VB and design the following screen!

Performing Integer Division and Using Mod! 1.Name your form frmDivision. 2.Change the caption of your form to Division. 3.Name the first button to cmdcalculate and second button cmdExit. 4.Name the first text box txtDivisor. 5.Name the second text box txtDividend. 6.Name the first label lblQuotient. 7.Name the third label lblRemainder.

Double click the calculate button. Enter the following code: 'Calculate Quotient lblQuotient.Caption=Val(txtDividend.Text) \ Val(txtDivisor.Text) 'Calculate Remainder lblRemainder.Caption = Val(txtDividend.Text) Mod Val(txtDivisor.Text) Run your program! What happens?

Worksheet! Create the program on your worksheet! Save to your flash drive. Bring back tomorrow for coding! Don’t forget to turn in your homework before you leave!!!!!!!