Results 1 to 5 of 5
  1. #1
    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...

    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!!

  2. #2
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    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

  3. #3
    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 23:12.
    **akuccputsedut**
    Intelligent is Me!!But a little confusing
    sometimes needs HELP!!

  4. #4
    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

  5. #5
    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!!

Posting Permissions

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