# Thread: change excel formula into visual basic

1. Registered User
Join Date
Jun 2007
Posts
35

## Unanswered: change excel formula into visual basic

hi everybody

anybody know how to change this excel formula into VB

(4*B57^3+(16*(B57^6)+(D57^6))^(0.5))^(1/3)+(4*B57^3-(16*(B57^6)+(D57^6))^(0.5))^(1/3)

B57 and D57 is input user that must devide by 2 first i have problem because of negatif please help anybody...

Private Sub cmdCal_Click()
Dim input1 As Double
Dim input2 As Double
Dim total1 As Double
Dim total2 As Double
Dim Sum As Double

input1 = Val(txtInput1.Text)
input2 = Val(txtInput2.Text)

total1 = input1 / 2
total2 = input2 / 2

Sum = (4 * total1 ^ 3 + (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5)) ^ (1 / 3) + (4 * total1 ^ 3) - (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5) ^ (1 / 3)

lblDisplay = Sum
End Sub

2. Registered User
Join Date
Apr 2004
Location
Derbyshire, UK
Posts
805
Hi

This

(4*B57^3+(16*(B57^6)+(D57^6))^(0.5))^(1/3)+(4*B57^3-(16*(B57^6)+(D57^6))^(0.5))^(1/3)

should equal this

Sum = (4 * total1 ^ 3 + (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5)) ^ (1 / 3) + (4 * total1 ^ 3 - (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5)) ^ (1 / 3)

??

MTB

3. Registered User
Join Date
Jun 2007
Posts
35
i did what you told me about the bracket but now it become error after i put the bracket there... Run -time error '5'
Invalid procedure call or argument

so, i change into this

Private Sub cmdCal_Click()
Dim input1 As Double
Dim input2 As Double
Dim total1 As Double
Dim total2 As Double

Dim Sum As Double

input1 = Val(txtInput1.Text)
input2 = Val(txtInput2.Text)

total1 = input1 / 2
total2 = input2 / 2

total3 = (4 * total1 ^ 3 + (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5)) ^ (1 / 3)
total4 = (4 * total1 ^ 3 - (16 * (total1 ^ 6) + (total2 ^ 6)) ^ (0.5)) ^ (1 / 3)

Sum = total3 + total4
lblDisplay = Sum
End Sub

but still run-time error it because of negatif in total 4 how to fix it...any idea...
Last edited by akuccputsedut; 08-14-07 at 22:12.

4. Village Idiot
Join Date
Jul 2003
Location
Michigan
Posts
1,941
Not that this is much help, but

According to Access help, if your number is a negative, then your exponent
has to be an integer. You are basically getting the same error you'd get if
you did SQRT(-1). You have a math problem, not a program problem.

5. Registered User
Join Date
Jun 2007
Posts
35

## yeah..

thank's friend...that right i have a math problem ... it work after i fix my math formula...
thank ya...

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•