Module: MathTrigonometry in Category General VBA/VB6 : Math from Total Visual SourceBook

Trigonometry functions for working with values such as cosines, tangents and secants in VBA and VB6.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modMathTrigonometry module.
ArcCoSecant Procedure Get the inverse cosecant of the supplied number.
ArcCosine Procedure Get the arc cosine of the supplied radians.
ArcCoTangent Procedure Get the inverse cotangent of the supplied number.
ArcSecant Procedure Get the inverse secant of the supplied number.
ArcSine Procedure Get the inverse sine of the supplied number.
ArcTangent Procedure Get the inverse tangent of the supplied numbers. Note that passing zero for both parameters returns a Null value, and causes an "Invalid Use of Null" error.
Cosecant Procedure Get the cosecant of the supplied radians. Note that sin(Radians) cannot equal zero. This can happen if dblRadians is a multiple of PI. In this case, the function returns a Null value, and causes an "Invalid Use of Null" error.
Cotangent Procedure Get the cotangent of the supplied radians. The function is undefined if input value is a multiple of PI.
HyperbolicArcCosecant Procedure Get the Inverse Hyperbolic Cosecant of the supplied number.
HyperbolicArcCosine Procedure Get the Inverse Hyperbolic Cosine of the supplied number.
HyperbolicArcCotangent Procedure Get the Inverse Hyperbolic Tangent of the supplied number. Undefined if dblIn is 1.
HyperbolicArcSecant Procedure Get the Inverse Hyperbolic Secant of the supplied number.
HyperbolicArcSine Procedure Get the Inverse Hyperbolic Sine of the supplied number.
HyperbolicArctan Procedure Get the Inverse Hyperbolic Tangent of the supplied number. The return value is undefined if input value is 1.
HyperbolicCosecant Procedure Get the Hyperbolic Cosecant of the supplied number.
HyperbolicCosine Procedure Get the Hyperbolic Cosine of the supplied number.
HyperbolicCotangent Procedure Get the Hyperbolic CoTangent of the supplied number.
HyperbolicSecant Procedure Get the Hyperbolic Secant of the supplied number.
HyperbolicSine Procedure Get the Hyperbolic Sine of the supplied number.
HyperbolicTangent Procedure Get the Hyperbolic Tangent of the supplied number.
Log10 Procedure Get log base 10. The power 10 must be raised to equal a given number.
Log Base 10 is defined as this: x = log(y) where y = 10 ^ x
Log2 Procedure Get log base 2. The power 2 must be raised to equal a given number.
Log base 2 is defined as this: x = log(y) where y = 2 ^ x
LogN Procedure Get log base N. The power N must be raised to equal a given number.
Log base N is defined as this: x = log(y) where y = N ^ x
Secant Procedure Get the secant of the supplied radians.
' Example of modMathTrigonometry
'
' To use this example, create a new module and paste this code into it.
' Then run the procedure by putting the cursor in the procedure and pressing:
'    F5 to run it, or
'    F8 to step through it line-by-line (see the Debug menu for more options)

Private Sub Example_modMathTrigonometry()
  ' Comments: Example of using the modMathTrigonometry module to calculate Trigonometry functions in VBA and VB6.
  '           See the results in the Immediate Window.

  Dim dbl1 As Double
  Dim dbl2 As Double
  Dim n As Integer

  dbl1 = 4.012
  dbl2 = 5.034

  Debug.Print "ArcCoSecant(): with input of " & dbl1 & " returned " & ArcCoSecant(dbl1)

  dbl1 = 0.0000943
  Debug.Print "ArcCosine(): with input of " & dbl1 & " returned " & ArcCosine(dbl1)

  Debug.Print "ArcCotangent(): with input of " & dbl1 & " returned " & ArcCoTangent(dbl1)

  dbl1 = 4.012
  Debug.Print "ArcSecant(): with input of " & dbl1 & " returned " & ArcSecant(dbl1)

  dbl1 = 0.0000943
  Debug.Print "ArcSine(): with input of " & dbl1 & " returned " & ArcSine(dbl1)

  Debug.Print "ArcTangent(): with input of " & dbl1 & " returned " & ArcTangent(dbl1, dbl2)

  Debug.Print "CoSecant(): with input of " & dbl1 & " returned " & Cosecant(dbl1)

  Debug.Print "CoTangent(): with input of " & dbl1 & " returned " & Cotangent(dbl1)

  Debug.Print "HyperbolicArcCosecant(): with input of " & dbl1 & " returned " & HyperbolicArcCosecant(dbl1)

  dbl1 = 4.012
  Debug.Print "HyperbolicArcCosine(): with input of " & dbl1 & " returned " & HyperbolicArcCosine(dbl1)

  Debug.Print "HyperbolicArcCotangent(): with input of " & dbl1 & " returned " & HyperbolicArcCotangent(dbl1)

  dbl1 = 0.0000943
  Debug.Print "HyperbolicArcSecant(): with input of " & dbl1 & " returned " & HyperbolicArcSecant(dbl1)

  Debug.Print "HyperbolicArcSine(): with input of " & dbl1 & " returned " & HyperbolicArcSine(dbl1)

  Debug.Print "HyperbolicArctan(): with input of " & dbl1 & " returned " & HyperbolicArctan(dbl1)

  Debug.Print "HyperbolicCosecant(): with input of " & dbl1 & " returned " & HyperbolicCosecant(dbl1)

  Debug.Print "HyperbolicCosine(): with input of " & dbl1 & " returned " & HyperbolicCosine(dbl1)

  Debug.Print "HyperbolicCotangent(): with input of " & dbl1 & " returned " & HyperbolicCotangent(dbl1)

  Debug.Print "HyperbolicSecant(): with input of " & dbl1 & " returned " & HyperbolicSecant(dbl1)

  Debug.Print "HyperbolicSine(): with input of " & dbl1 & " returned " & HyperbolicSine(dbl1)

  Debug.Print "HyperbolicTangent(): with input of " & dbl1 & " returned " & HyperbolicTangent(dbl1)

  Debug.Print "Secant(): with input of " & dbl1 & " returned " & Secant(dbl1)
  Debug.Print

  ' Displays to the immediate window log values.
  ' Every unit increase represents a power of 10.
  Debug.Print "Log Base 10 of 1 is " & Log10(1)
  Debug.Print "Log Base 10 of 10 is " & Log10(10)
  Debug.Print "Log Base 10 of 100 is " & Log10(100)
  Debug.Print "Log Base 10 of 5 is " & Log10(5)
  Debug.Print "2 ^ " & Log10(5) & " = 5"
  Debug.Print

  ' Displays to the immediate window log values.
  ' Every unit increase represents a power of 2.
  Debug.Print "Log Base 2 of 1 is " & Log2(1)
  Debug.Print "Log Base 2 of 2 is " & Log2(2)
  Debug.Print "Log Base 2 of 4 is " & Log2(4)
  Debug.Print "Log Base 2 of 5 is " & Log2(5)
  Debug.Print "2 ^ " & Log2(5) & " = 5"
  Debug.Print

  ' Displays to the immediate window log values.
  ' Every unit increase represents a power of 10.
  For n = 2 To 10
    Debug.Print "Log Base " & n & " of 10 is " & LogN(10, n)
  Next n

End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS