Visual Basic I Programming

Slides:



Advertisements
Similar presentations
Subprograms Functions Procedures. Subprograms A subprogram separates the performance of some task from the rest of the program. Benefits: “Divide and.
Advertisements

Sub and Function Procedures
The Circular Functions (14.2)
The Inverse Trigonometric Functions Section 4.2. Objectives Find the exact value of expressions involving the inverse sine, cosine, and tangent functions.
Copyright © Cengage Learning. All rights reserved. Trigonometric Functions: Unit Circle Approach.
1.
Pre calculus Problem of the Day Homework: p odds, odds, odds On the unit circle name all indicated angles by their first positive.
Writing General Procedures Often you will encounter programming situations in which multiple procedures perform the same operation This condition can occur.
Unit 34 TRIGONOMETRIC FUNCTIONS WITH RIGHT TRIANGLES.
Trigonometric Functions on Any Angle Section 4.4.
INTRODUCTION TO TRIGONOMETRIC FUNCTIONS
Reciprocal Trig Functions Section The Reciprocal Functions  cosecant (csc θ)=  secant (sec θ)=  cotangent (cot θ)=
Chapter 6: Trigonometry 6.1: Right-Triangle Trigonometry
Inverse Trigonometric Functions The definitions of the inverse functions for secant, cosecant, and cotangent will be similar to the development for the.
 Angles and Degree Measure › An angle is formed by two rays with a common endpoint › That endpoint is called the vertex › Angles can be labeled by the.
Trigonometric Functions of Any Angle & Polar Coordinates
Apply Sub Procedures/Methods and User Defined Functions
Objectives ► The Inverse Sine Function ► The Inverse Cosine Function ► The Inverse Tangent Function ► The Inverse Secant, Cosecant, and Cotangent Functions.
5.1 Trigonometric Functions of Acute Angles Fri Oct 17 Do Now Solve for x 1) 1^2 + x^2 = 2^2 2) x^2 + x^2 = 1.
Right Triangle Trigonometry. Degree Mode v. Radian Mode.
3.5 – Derivative of Trigonometric Functions
Why to Create a Procedure
Warm-up:. Homework: 7.5: graph secant, cosecant, tangent, and cotangent functions from equations (6-7) In this section we will answer… What about the.
CSC 162 Visual Basic I Programming. Randomizing and Formatting Randomizing Formatting –User-Defined Formats –Named Numeric Formats.
1 A unit circle has its center at the origin and a radius of 1 unit. 3.3 Definition III: Circular Functions.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Fund Raiser Application Introducing Scope, Pass-by-Reference and Option Strict.
1 © 2010 Pearson Education, Inc. All rights reserved © 2010 Pearson Education, Inc. All rights reserved Chapter 4 Trigonometric Functions.
110-G1 Motivation: Within a program, may have to perform the same computation over and over Many programs share the same computation (e.g. sorting) To.
Copyright © Cengage Learning. All rights reserved. Trigonometric Functions: Unit Circle Approach.
13.7 (part 2) answers 34) y = cos (x – 1.5) 35) y = cos (x + 3/(2π)) 36) y = sin x –3π 37) 38) y = sin (x – 2) –4 39) y = cos (x +3) + π 40) y = sin (x.
CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Writing JavaScript Functions.
Writing JavaScript Functions. Goals By the end of this unit, you should understand … How to breakdown applications into individual, re-usable modules.
CSC 162 Visual Basic I Programming. Array Parameters and Sorting Array Parameters –Entire Arrays –Individual Elements Sorting –Bubble Sort.
Graphs of the Trig Functions Objective To use the graphs of the trigonometric functions.
1 What you will learn  How to find the value of trigonometric ratios for acute angles of right triangles  More vocabulary than you can possibly stand!
Visual Basic I Programming
Finding Trigonometric Function Values using a Calculator Objective: Evaluate trigonometric functions using a calculator.
5.2 – Day 1 Trigonometric Functions Of Real Numbers.
Variables & Function Calls. Overview u Variables  Programmer Defined & Intrinsic  Data Types  Calculation issues u Using Functions  The val() function.
1 © 2011 Pearson Education, Inc. All rights reserved 1 © 2010 Pearson Education, Inc. All rights reserved © 2011 Pearson Education, Inc. All rights reserved.
Reciprocal functions secant, cosecant, cotangent Secant is the reciprocal of cosine. Reciprocal means to flip the ratio. Cosecant is the reciprocal of.
Trigonometric Functions of Any Angle & Polar Coordinates
8-2 Trigonometric Ratios Warm Up Lesson Presentation Lesson Quiz
4.2 Trig Functions of Acute Angles. Trig Functions Adjacent Opposite Hypotenuse A B C Sine (θ) = sin = Cosine (θ ) = cos = Tangent (θ) = tan = Cosecant.
Graphing Primary and Reciprocal Trig Functions MHF4UI Monday November 12 th, 2012.
Use Reference Angles to Evaluate Functions For Dummies.
Subroutines and Functions Chapter 6. Introduction So far, all of the code you have written has been inside a single procedure. –Fine for small programs,
Sub Procedures and Functions Visual Basic. Sub Procedures Slide 2 of 26 Topic & Structure of the lesson Introduction to Modular Design Concepts Write.
Visual Basic I Programming
Trigonometric Functions: The Unit Circle
Do Now The terminal side of angle θ in standard position passes through the point (12, 16). Find the value of the six trigonometric functions of angle.
Section 4.2 The Unit Circle.
Introduction to the Six Trigonometric Functions & the Unit Circle
Pre-Calc: 4.2: Trig functions: The unit circle
T2.1 d To Use The Calculator To Find All Trig Values
1.الدوال Function 2.الاجراءاتSub Procedure 3.وحده نمطيه Add Module
Trigonometry Review.
Trigonometric Functions
Right Triangle Ratios Chapter 6.
Warm-Up: February 3/4, 2016 Consider θ =60˚ Convert θ into radians
Calculating Cosecant, Secant, and cotangent
Right Triangle Ratios Chapter 6.
5.2 Trigonometric Functions of Real Numbers
Right Triangle Trigonometry
Procedures: Functions and Subroutines
The Inverse Trigonometric Functions (Continued)
Trigonometric Functions: The Unit Circle
Inverse Trig Functions
Academy Algebra II THE UNIT CIRCLE.
10.2 Procedures Passing Parameters 30/08/2019.
Presentation transcript:

Visual Basic I Programming CSC 162 Visual Basic I Programming

Arguments and Modules Sub Procedures vs. Functions Arguments (Parameters) ByVal and ByRef Usage Guidelines Optional Arguments Positional vs. Named Argument Association Modules

Sub Procedures vs. Functions Perform some “action”. Take in arguments (parameters). Can return value(s) by using ByRef argument(s). Functions: Perform some “calculation”. Return a single value through the function’s name.

ByVal and ByRef Usage Guidelines Use ByVal when: Parameter is only being read in to the function or sub procedure Use ByRef when: Parameter is only being sent out of the sub procedure Parameter is being read in to and sent out of the sub procedure

Optional Arguments Requirements: Example: Non-optional arguments must be listed before optional arguments. Each optional argument must have the reserved word Optional before it. Each optional argument must be given a default value. Example: Procedure declaration: Private Sub PrintArea(ByVal intX As Integer, _ Optional intY As Integer = 1) Call to procedure: Call PrintArea(5) ' intX=5, intY=1 Call PrintArea(7, 9) ' intX=7, intY=9

Positional vs. Named Argument Association Positional Argument Association Each argument is passed in to the procedure according to its position in the parentheses. Example: Procedure declaration: Private Sub PrintVolume(Optional intX As Integer = 1, _ Optional intY As Integer = 1, _ Optional intZ As Integer = 1) Call to procedure: Call PrintVolume(2, 3, 5) ' intX=2, intY=3, intZ=5 Call PrintVolume() ' intX=1, intY=1, intZ=1 Call PrintVolume(1, 1, 5) ' intX=1, intY=1, intZ=5 Call PrintVolume(, , 5) ' intX=1, intY=1, intZ=5 Call PrintVolume(4, , 5) ' intX=4, intY=1, intZ=5

Positional vs. Named Argument Association Each argument is passed in to the procedure according to its name in the procedure declaration. Example: Procedure declaration: Private Sub PrintVolume(Optional intX As Integer = 1, _ Optional intY As Integer = 1, _ Optional intZ As Integer = 1) Call to procedure: Call PrintVolume(intX:=2, intY:=3, intZ:=5) ' intX=2, intY=3, intZ=5 Call PrintVolume(intY:=3, intZ:=5, intX:=2) ' intX=2, intY=3, intZ=5 Call PrintVolume() ' intX=1, intY=1, intZ=1 Call PrintVolume(intZ:=5) ' intX=1, intY=1, intZ=5 Call PrintVolume(intX:=4, intZ:=5) ' intX=4, intY=1, intZ=5

Positional vs. Named Argument Association Example: Procedure declaration: Private Function Product(ByVal sngA As Single, _ ByVal sngB As Single) As Single Call to procedure: sngAnswer = Product(3, 5) ' sngA=3, sngB=5 sngAnswer = Product(sngA:=3, sngB:=5) ' sngA=3, sngB=5 sngAnswer = Product(sngB:=5, sngA:=3) ' sngA=3, sngB=5 sngAnswer = Product(5, 3) ' sngA=5, sngB=3

Modules A module is a file that contains only code. It is has no GUI associated with it. It is stored in a file with a .bas extension. Its code can be made available (Public) to other forms, modules, etc. in the same project. Since it is a stand-alone file, its code can be reused in other projects.

Programming Assignment 5 Lab Assignment Write a function DegToRad that converts an angle in degrees to radians. Use this function in a program that allows the user to input an angle (measured in degrees) in a textbox, and then computes the sine, cosine, tangent, cosecant, secant, and cotangent. Display these values in six textboxes with appropriate labels. Round all answers to four (4) decimal places Programming Assignment 5 Due Monday, November 10 / Tuesday, November 11 Page 241 #6.18 Page 241 #6.19