My program does not reconize the PI() or the ASIN() and those types of functions. It does reconize SIN() and those trig functions. Is there something I need to add-in to my program?
PI is not a builtin function. You will need to write your own. The only intrinsic trig functions are Sin, Cos, ATan and Tan. You need to use Trig identities to compute the others. For example ArcSin is
[blue][tt]
'====================================================================================
' Compute the ArcSin of an angle
'====================================================================================
Public Function ArcSin(x As Double) As Double
If x < -1# Then x = -1#
If x > 1# Then x = 1#
Const PI As Double = 3.14159265
If x = -1 Then
ArcSin = (3# * PI) / 2#
ElseIf x = 1 Then
ArcSin = PI / 2#
Else
' Trig Identity - Undefined at ±1
ArcSin = Atn(x / Sqr(-x * x + 1))
End If
In VB6 most of the trig functions need to be derived by you in code from basics. The native functions are sin(), cos(), tan() and atn().
All the others are derived from those. There is a full list of derived trig functions in VBHelp, under 'Derived Math Functions'
Pi can be evauated as 4 * Atn(1)
Don't forget that all trig functions in VB use radians not degrees.
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Thanks to both of you for your help. I can do the math you talked about and now remember that fact from programing in quickbasic. However the help features show both atan() and pi() as well as other math functions as valid functions. Do either of you know why it is shown in the help? Just curious.
I guess you're looking at Visual Studio help, which covers SQL and Visual Foxpro, amongst others. These functions are supported in both those applications, but not VB6
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
You're welcome - and to get the best from the forum, faq222-2244 gives an intro and some guidelines on getting the best from the forum.
Enjoy
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.