Siebel VB Language Reference > VB Language Reference >

Cos Function


This standard VB function returns the cosine of an angle.

Syntax

Cos(number)

Argument
Description

number

An angle in radians

Returns

The cosine of number.

Usage

The return value is between -1 and 1. The return value is a single-precision number if the angle has a data type of integer or currency, or is a single-precision value. The return value is a double-precision value if the angle has a data type of long or variant, or is a double-precision value.

The angle can be either positive or negative. To convert degrees to radians, multiply by (PI/180). The value of PI is approximately 3.14159.

Example

This example finds the length of a roof, given its pitch and the distance of the house from its center to the outside wall.

Sub Button_Click
   Dim bwidth As Single, roof As Single, pitch As Single
   Dim msgtext
   Const PI = 3.14159
   Const conversion = PI/180
   pitch = 35
   pitch = Cos(pitch * conversion)
   bwidth = 75
   roof = bwidth/pitch
   msgtext = "The length of the roof is " & _
      Format(roof, "##.##") & " feet."
End Sub

See Also

Atn Function
Sin Function
Tan Function
Derived Trigonometric Functions for Siebel VB

Siebel VB Language Reference