Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2012 EMC Publishing, LLC Slide 1 Chapter 7 The Math Class  Includes shared methods that perform common math functions.  Math Class methods include:

Similar presentations


Presentation on theme: "© 2012 EMC Publishing, LLC Slide 1 Chapter 7 The Math Class  Includes shared methods that perform common math functions.  Math Class methods include:"— Presentation transcript:

1 © 2012 EMC Publishing, LLC Slide 1 Chapter 7 The Math Class  Includes shared methods that perform common math functions.  Math Class methods include: Abs(num)returns the absolute value of num. Sqrt(num)returns the square root of num. Sign(num)returns 1, -1, or 0 when num is positive, negative, or 0 respectively. Round(num, places)returns a Double representing num rounded to ( a specified number ) places places.

2 © 2012 EMC Publishing, LLC Slide 2 Chapter 7 The IsNumeric() Function  Returns True if an argument can be evaluated to a number. False returned otherwise. For example: text = "123" Me.lblAns.Text = IsNumeric(text)'True text = "1 + 2" Me.lblAns.Text = IsNumeric(text)'False  Member/Method of Information module

3 © 2012 EMC Publishing, LLC Slide 3 Chapter 7 The Format() Function  Converts a number to a formatted string.  Member/Method of Strings Class/Module  Include: Currency, Fixed, Percent, Scientific and True/False: '$4,568.00 Me.lblNum.Text = Format(4568, "Currency") '4568.00 Me.lblNum.Text = Format(4568, "Fixed") '45% Me.lblNum.Text = Format(.45, "Percent") 'True Me.lblNum.Text = Format(1, "True/False") ‘3.14E-09 Me.lblNum.Text = Strings.Format(Math.PI / 1000000000, "Scientific")

4 © 2012 EMC Publishing, LLC Slide 4 Chapter 7 Business Functions  An annuity is a set of payments made on a regular basis for a specified period.  Functions that return information about an annuity: - Pmt(rate, term, principal) calculates the daily/monthly/yearly payment on a loan->rate and term must match: daily/monthly/yearly - PV(rate, term, amount) returns the present value of an annuity->rate, term and amount must match - FV(rate, term, amount) returns the future value of an annuity->rate, term and amount must match

5 © 2012 EMC Publishing, LLC Slide 5 Chapter 7 Processing Business Data  Business applications that prompt the user for currency values and percentage rates should be written to accept a variety of formats. User should be allowed to enter $45000 or 45000. If code not written to accept both formats a run-time error will occur.  The IsNumeric() function returns True when a string of numbers begins with a $. However Val() returns 0 for Val(“$45”) because $ is not recognized.

6 Chapter 7 Processing Business Data  The Replace() String method can be used to find and replace the $ and any commas with empty strings before converting the string using the Val() function.  The TrimEnd() String method can be used to remove the % before converting the string using the Val() function. © 2012 EMC Publishing, LLC Slide 6

7 © 2012 EMC Publishing, LLC Slide 7 Chapter 7 The ListBox Control  (Name) should begin with lst.  Items is used to add a set of strings to the box.  Sorted is set to True to display the list items in alphabetical order.  SelectedItem is the selected item.  SelectedIndex is the index of the selected item.

8 © 2012 EMC Publishing, LLC Slide 8 Chapter 7 The ListBox Control Class Methods  Items.Add() is used to add an item to a list box at run time.  Items.Remove() is used to delete a specified item from the list box.  Items.Clear() deletes the contents of the list box.

9 © 2012 EMC Publishing, LLC Slide 9 Chapter 7 The ComboBox Control  (Name) should begin with cbo.  Items is used to add a set of strings to the box.  Text is the text displayed in the text box of the combo box.  Sorted is set to True to display the list items in alphabetical order.  SelectedItem is the selected item.  SelectedIndex is the index of the selected item.

10 © 2012 EMC Publishing, LLC Slide 10 Chapter 7 The ComboBox Control Class Methods  Items.Add() is used to add an item to a combo box at run time.  Items.Remove() is used to delete a specified item from the combo box.  Items.Clear() deletes the contents of the combo box.

11 © 2012 EMC Publishing, LLC Slide 11 Chapter 7 Windows Application Standards

12  The object with focus( contains insertion point/prompt ) will receive the user input from the keyboard.  An access key is the key pressed while holding down the Alt key to select an object. (&) is used in the Text property to define an access key. Access keys are not displayed until Alt is pressed.  A disabled object cannot be selected by the user. Enabled property is used.  A logical tab order can be set by the order in which objects are added to a form. This order can be changed by setting the TabIndex property of the objects ( first is 0 = initial focus ). © 2012 EMC Publishing, LLC Slide 12

13 © 2012 EMC Publishing, LLC Slide 13  Math class trig methods include: Sin(angle)returns the sine of angle. Cos(angle)returns the cosine of angle. Tan(angle)returns the tangent of angle.  The Sin(), Cos(), and Tan() methods require an argument in radians.  To convert from degrees to radians, use the Math class PI constant: radians = (Math.PI / 180) * degrees Chapter 7 The Math Class Trigonometric Methods

14 © 2012 EMC Publishing, LLC Slide 14 Math class inverse trig methods include:  Asin(num)returns the arcsine of num (in radians)  Ac os(num)returns the arccosine of num (in radians)  At an(num)returns the arctangent of num (in radians). Chapter 7 The Math Class Inverse Trigonometric Methods

15 © 2012 EMC Publishing, LLC Slide 15  Math class logarithmic methods include: Log(num)returns the natural logarithm (base e) of num. Log(num, base)returns the logarithm of num in the specified base base. Log10(num)returns the base 10 logarithm of num. Exp(power) returns e raised to a power. Pow(num, power)returns num raised to the power power.  The Math also includes the constant E which represents the base of natural logarithms. Chapter 7 The Math Class Logarithmic and Exponential Methods


Download ppt "© 2012 EMC Publishing, LLC Slide 1 Chapter 7 The Math Class  Includes shared methods that perform common math functions.  Math Class methods include:"

Similar presentations


Ads by Google