Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Answer not doubling for correct response

Posted on 2009-02-21
Medium Priority
Last Modified: 2013-11-13
Within my formula code, I cannot get my response to properly display the output of the Pythagorean theorem formula: a2 + b2 = c2. How do I properly code to get correct response?
Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
        If Theorem.Checked Then
            txtOutput.Text = Math.Pow(NUDradius.Value, 2) + Math.Pow(NUDheight.Value, 2)
        ElseIf Cylinder.Checked Then
            'cylinder volume
            txtOutput.Text = Math.Pow(NUDradius.Value, 2) * NUDheight.Value * Math.PI
        End If
    End Sub

Open in new window

Question by:probeg
LVL 39

Accepted Solution

abel earned 2000 total points
ID: 23701057
What do you mean with incorrect? The result of your formula is the quadrature of the hypotenuse, which, to show up as the length of the hypotenuse, first has to be square rooted:

Math.Sqrt(Math.Pow(NUDradius.Value, 2) + Math.Pow(NUDheight.Value, 2))

Btw: I don't know what NUDradius is, but it sounds like something of the radius of a circle, are you sure that's the value you need? Shouldn't it be something like height / width of the rectangle/triangle?

Expert Comment

by:Ken Fayal
ID: 23701063
If you are trying to obtain the value of c then you need to use the following:

txtOutput.Text = Math.Sqrt(Math.Pow(NUDradius.Value, 2) + Math.Pow(NUDheight.Value, 2))

Open in new window


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question