See Also Example
Returns the cosine of an angle.
The argument angle can be any valid numeric expression measured in radians.
The Cos function takes an angle and returns the ratio of two sides of a right triangle. The ratio is the length of the side adjacent to the angle divided by the length of the hypotenuse.
The result lies in the range -1 to 1.
To convert degrees to radians, multiply degrees by Pi/180. To convert radians to degrees, multiply radians by 180/Pi. Pi is approximately 3.141593.
Derived Math Functions
Cos Function Example
The example uses Cos to calculate the cosine of an angle with a user-specified number of degrees. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Degrees, Msg, Pi, Radians ' Declare variables.
Pi = 4 * Atn(1) ' Calculate Pi.
Degrees = InputBox("Enter an angle in degrees.") ' Get user input.
Radians = Degrees * (Pi / 180) ' Convert to radians.
Msg = "The cosine of a " & Degrees
Msg = Msg & " degree angle is "
Msg = Msg & Cos(Radians) & "."
MsgBox Msg ' Display results.