If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > change excel formula into visual basic

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-13-07, 21:29
akuccputsedut akuccputsedut is offline
Registered User
 
Join Date: Jun 2007
Posts: 35
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...

This what i did but answer that it calculate not same as answer in excel maybe it wrong somewhere...please help

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
__________________
**akuccputsedut**
Intelligent is Me!!But a little confusing
sometimes needs HELP!!
Reply With Quote
  #2 (permalink)  
Old 08-14-07, 03:35
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Hi

your bracketing is different.

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
Reply With Quote
  #3 (permalink)  
Old 08-14-07, 21:54
akuccputsedut akuccputsedut is offline
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...
__________________
**akuccputsedut**
Intelligent is Me!!But a little confusing
sometimes needs HELP!!

Last edited by akuccputsedut; 08-14-07 at 22:12.
Reply With Quote
  #4 (permalink)  
Old 08-15-07, 09:21
RedNeckGeek RedNeckGeek is offline
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.
__________________
Inspiration Through Fermentation
Reply With Quote
  #5 (permalink)  
Old 08-15-07, 22:57
akuccputsedut akuccputsedut is offline
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...
__________________
**akuccputsedut**
Intelligent is Me!!But a little confusing
sometimes needs HELP!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On