Home > Archive > Visual Basic Syntax > March 2005 > SQR and friends
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| I known VB6 has a SQR function, but is there a function to get an
arbitrary (including fractional) root of a number? Thanks!
Danny
(You guessed it! Remove NOSPAMFOR before emailing.)
| |
| David Youngblood 2005-03-05, 9:02 pm |
| "Danny" <NOSPAMFORdaniel_ahorn@yahoo.com> wrote...
> I known VB6 has a SQR function, but is there a function to get an
> arbitrary (including fractional) root of a number? Thanks!
The formula is X ^ (1 / Y)
Private Function Root(ByVal X As Double, ByVal Y As Double) As Double
Root = X ^ (1 / Y)
End Function
Private Sub Command1_Click()
Debug.Print Root(16, 2) ' square root
Debug.Print Root(125, 3) ' cube root
Debug.Print Root(1921, 7.534) ' any root
End Sub
David
| |
|
| Date: Sat, 5 Mar 2005 15:59:17 -0600
Name: "David Youngblood" <dwy@flash.net>
>"Danny" <NOSPAMFORdaniel_ahorn@yahoo.com> wrote...
>
>The formula is X ^ (1 / Y)
>
>Private Function Root(ByVal X As Double, ByVal Y As Double) As Double
> Root = X ^ (1 / Y)
>End Function
>
>Private Sub Command1_Click()
> Debug.Print Root(16, 2) ' square root
> Debug.Print Root(125, 3) ' cube root
> Debug.Print Root(1921, 7.534) ' any root
>End Sub
>
>David
Thank you very much, David!
Danny
(You guessed it! Remove NOSPAMFOR before emailing.)
|
|
|
|
|