CS4 –lecture 6 Wednesday, Jan 19, 2011 Roxana Gheorghiu.

Slides:



Advertisements
Similar presentations
Input Dialog Box An input dialog box can be used to obtain a single item of input from the user Presents a window (dialog box) requesting input Syntax:
Advertisements

Python November 14, Unit 7. Python Hello world, in class.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Section 3.6 BUILT-IN FUNCTIONS involving numbers & strings.
Copyright © 2001 by Wiley. All rights reserved. Chapter 3: Variables, Assignment Statements, and Arithmetic Variables Assignment Statements Arithmetic.
Variables & Math Operators CE 311 K - Introduction to Computer Methods Daene C. McKinney.
Chapter 5 new The Do…Loop Statement
Chapter 31 Fundamentals of Programming in Visual Basic (Continue VI) String Properties and Methods: "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
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.
CS0004: Introduction to Programming Variables – Numbers.
CS0004: Introduction to Programming Input and Output.
CS0004: Introduction to Programming Relational Operators, Logical Operators, and If Statements.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 3 - VB.NET by Schneider1 Chapter 3 – Fundamentals of Programming in VB.NET VB.NET Controls VB.NET Events Numbers Strings Input and Output.
CS0004: Introduction to Programming Variables – Strings.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
IMS 3253: Math 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Five Fundamental Math Operations Precedence of Math.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
Lecture 8 Visual Basic (2).
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
More on Objects. Goals By the end of this unit you should … … be able to identify selected String properties … be able to identify and use selected String.
1 INF110 Visual Basic Programming AUBG Spring semester 2011 Reference books: Schneider D., An Introduction to Programming Using Visual Basic, Prentice.
Numbers continued The Integer Data Type Multiple Declarations Parentheses Three Types of Errors.
Chapter 8 - Visual Basic Schneider
Variables, Expressions and Statements
CS 0004 –Lecture 3 Jan 10, 2011 Roxana Gheorghiu.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
Mathematical Calculations in Java Mrs. C. Furman.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
1 Chapter 3 – Examples The examples from chapter 3, combining the data types, variables, expressions, assignments, functions and methods with Windows controls.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Hungarian Notation A must in this course Every object used MUST be renamed including the form(s) using the following rules Form  frmFormName E.g. frmTemperature.
Chapter 6 Looping Structures. Do…LoopDo…Loop Statement Can operate statements repetitively Do intx=intx + 1 Loop While intx < 10 –The Loop While operates.
Variables Hold information that may be manipulated, used to manipulate other information or remembered for later use A storage location in memory (RAM)
CECS 5020 Computers in Education Visual Basic Variables and Constants.
110 E-1 Variables, Constants and Calculations(2) Chapter 3: Operations on variables, scope of a variable, formatting data Doing Arithmetic.
© 2006 Lawrenceville Press Slide 1 Chapter 6 The Post-Test Do…Loop Statement  Loop structure that executes a set of statements as long as a condition.
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.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Creation of Variables with Numeric, alphanumeric, date, picture, memo data types Constant - A quantity that does not change during the execution of a program.
Chapter 3 - VB 2008 by Schneider1 Chapter 3 – Variables, Input, and Output 3.1 Numbers 3.2 Strings 3.3 Input and Output.
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”
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
An Application Uses Variables to Hold Information So It May Be Manipulated, Used to Manipulate Other Information, or Remembered for Later Use.
Visual Basic Variables
2.5 Another Java Application: Adding Integers
Variables and Arithmetic Operations
Variables, Expressions, and IO
Chapter 3 – Variables, Input, and Output
VB Math All of your favorite mathematical operators are available in VB: + Addition - Subtraction * Multiplication / Division \ Integer Division Mod Modulo.
Arithmetic Operator Operation Example + addition x + y
Variables and Arithmetic Operations
Chapter 5 The Do…Loop Statement
Chapter 3 – Variables, Input, and Output
Fundamentals of Programming in VB.NET
Numbers.
Strings(Part 1) String Literal and String Variable
String Variable, Methods and Properties
Section 3.3 Numbers Arithmetic Operations Variables
Variable Review & IO User 12/26/2018.
String Variable, Methods and Properties
Additional Topics in VB.NET
String Variable, Methods and Properties
String Variable, Methods and Properties
Chapter 2: Java Fundamentals cont’d
Text Copyright (c) 2017 by Dr. E. Horvath
Introduction to Python
Presentation transcript:

CS4 –lecture 6 Wednesday, Jan 19, 2011 Roxana Gheorghiu

Standard Arithmetic Operations: Addition (+) Subtraction (-) Division (/) Multiplication (*) Exponentiation (^) Level of precedence for arithmetic operations: Numbers and Arithmetic Operations

Standard Arithmetic Operations -Level of precedence for arithmetic operations: Addition (+) Subtraction (-) Division (/) Multiplication (*) Exponentiation (^) Numbers and Arithmetic Operations

Level of precedence for arithmetic operations: Addition (+) Subtraction (-)-LEVEL 3 Division (/) Multiplication (*)-LEVEL 2 Exponentiation (^) –LEVEL 1 NOTE: 1/0 = Infinity Math.Sqrt(-4) =NaN(Not a Number) Numbers and Arithmetic Operations

Modulo : x Mod y =the reminder when m is divided my n Ex: 20 Mod 2 =0 15 Mod 4 =3 Square root: Math.Sqrt( #number) Ex: Math.Sqrt(9) =3 Built-In Functions

The greatest integer less than or equal to a number: Int(#number) Ex: Int(2.7) =2 Int(-2.7) =-3 Rounding a number to r decimal places: Math.Round(#number, #r) or Math.Round(#number) Math.Round(2.14, 1) =2.1 Math.Round(2.67) =3 Built-In Functions (cont.)

Var = expression (1) Dim myNumber as Double myNumber =5.21 (2) Dim myNumber as Double =5.21 NOTE: Dim x as Integer =3, y as Double =5.3 Assignment Statement

Dim str as String =“ My own String ” Length() =returns the number of characters in the string str.Length ->19 ToUpper() =returns the string with letters capitalized str.ToUpper() ->” MY OWN STRING “ ToLower() =returns the string with all letters in lowercase format Str.ToLower() -> “ my own string “ Trim() =returns the string with all spaces removed from the front and back of the string str.Trim() -> “My own String” String Properties and Methods

Dim str as String =“ My own String ” Dim str2 as String = “own” Substring (m,n) =the substring that starts at position m and its n characters long IndexOf(newString) str.IndexOf(str2) =str.IndexOf(“own”) returns: 6 str.Substring(0,5) returns: “ My” Clear()=creates an empty string str.Clear() str.Txt=“” String Properties and Methods

CStr(number) or number.ToString converts a number into a string CInt(string) converts a String into an Integer value CDbl(string) converts a String into a Double value & used to concatenate two strings str =“One” ; str1 =“ and two” str & str1 returns: “One and two” _ the continuation character String Properties and Methods

stringVar =textBox.Text Ex: Dim str as String str =txtName.Text If the input data will be used in a MATH expression you will need first to convert it to Double or Integer and then use it Input Data from a Text Box

stringVar = InputBox(prompt, title) Ex: Dim name as String Dim prompt, title as String prompt =“Please give a name” title =“Input box for a name” name =InputBox(prompt, title) Input Data from Dialog Box

MsgBox(prompt, button, title) Ex: MsgBox (“Congratulation !”, 0, “Result Window”) OR MsgBox (“Congratulation !”) -> in this case the title is the same string as the name of the main window Note: check *Dailly Schedule* on for a complete list of possible values for variable button Output Data Using a Message Box

(1) Write a VB program that asks a name as input and it will copy that name in a list. (2) Write a VB program that asks a name as input and it will copy the first name in one list and the last name in another list (3) Continue exercise (2) by adding a new button Del, that will delete an entry selected from any list. Application