Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Playonu
    New Member
    • Jul 2008
    • 4

    Help

    Try to run this full program and u will see that it has few errors.
    I would be grateful if u included corrected in an answer post.
    It is in VB 5.
    Thanks for your attention.
    Private Sub Command1_Click( )
    Dim x, y, z, w, v, a, b As Double
    MsgBox "give a"
    InputBox a
    MsgBox "give b"
    InputBox b
    If a = 0 Or b = 0 Then
    MsgBox "The solutions can not be given by that program!"
    Else
    MsgBox "ok please wait...."
    End If
    If a ^ 4 - (256 * b ^ 3) / 27 >= 0 Then
    z = ((a ^ 2 + (a ^ 4 - (256 * b ^ 3) / 27) ^ 1 / 2) / 2) ^ 1 / 3 + ((a ^ 2 - (a ^ 4 - (256 * b ^ 3) / 27) ^ 1 / 2) / 2) ^ 1 / 3
    Else
    MsgBox "The solutions can not be given by that program!"
    End If
    If z >= 0 And -z - (2 * a) / z ^ 1 / 2 >= 0 Then
    x = (z ^ 1 / 2 + (-z - (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
    w = (z ^ 1 / 2 - (-z - (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
    Else
    If z >= 0 And -z + (2 * a) / z ^ 1 / 2 >= 0 Then
    y = (z ^ 1 / 2 + (-z + (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
    v = (z ^ 1 / 2 - (-z + (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
    Else
    If z < 0 Then
    MsgBox "There are no other real solutions"
    End If
    MsgBox "The first solution is" 'x'
    MsgBox "The second solution is" 'w'
    MsgBox "The third solution is" 'y'
    MsgBox "The fourth solution is" 'v'
    MsgBox "There is no other real solution"
    MsgBox "Thanks for using that program"
    End

    ...



    ...
    End sub
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    you run the program and post back here with the part that is throwing error.

    Comment

    • Playonu
      New Member
      • Jul 2008
      • 4

      #3
      Originally posted by debasisdas
      you run the program and post back here with the part that is throwing error.
      Don't u have a VB 5?
      The problem is that there is not a specific problem!

      Comment

      • smartchap
        New Member
        • Dec 2007
        • 236

        #4
        I have corrected the program in VB6 as I don't have VB5. You can modify it for VB5.

        Private Sub Command1_Click( )
        Dim x, y, z, w, v, a, b As Double
        'MsgBox "give a"
        a = InputBox("give a")
        'MsgBox "give b"
        b = InputBox("give b")
        If a = 0 Or b = 0 Then
        MsgBox "The solutions can not be given by this program!"
        End
        Else
        MsgBox "ok please wait...."
        End If
        MsgBox a ^ 4 - (256 * b ^ 3) / 27
        If a ^ 4 - (256 * b ^ 3) / 27 >= 0 Then
        z = ((a ^ 2 + (a ^ 4 - (256 * b ^ 3) / 27) ^ 1 / 2) / 2) ^ 1 / 3 + ((a ^ 2 - (a ^ 4 - (256 * b ^ 3) / 27) ^ 1 / 2) / 2) ^ 1 / 3
        Else
        MsgBox "The solutions can not be given by this program!"
        End
        End If
        If z >= 0 Then
        If -z - (2 * a) / z ^ 1 / 2 >= 0 Then
        x = (z ^ 1 / 2 + (-z - (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
        w = (z ^ 1 / 2 - (-z - (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
        ElseIf -z + (2 * a) / z ^ 1 / 2 >= 0 Then
        y = (z ^ 1 / 2 + (-z + (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
        v = (z ^ 1 / 2 - (-z + (2 * a) / z ^ 1 / 2) ^ 1 / 2) / 2
        End If
        Else
        MsgBox "There are no other real solutions"
        End If
        MsgBox "The first solution is" & x
        MsgBox "The second solution is" & w
        MsgBox "The third solution is" & y
        MsgBox "The fourth solution is" & v
        MsgBox "There is no other real solution"
        MsgBox "Thanks for using the program"
        End Sub


        It works fine in Vb6 after corrections as above.

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Originally posted by Playonu
          Don't u have a VB 5?
          The problem is that there is not a specific problem!
          Behave yourself. Do not expect others to write code for you. When you face problem in specific part of the code you need to mention that part only.

          Comment

          Working...