Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2009

    Unanswered: Help Needed in Visual Basic 2008 coding

    I have a problem (this is for school), and I am stuck. This is from a similar post back from March, on the pythagorean Theorum or Cylinder Volume. I have the code entered and have no errors, but the only thing is when I run the calculate button when debugging, no matter what the numericUpDown buttons show, 1, 2, or 5 etc, my txtResult box still reflects 0. Can somebody please tell me what I am missing from my code? I'm so close I can almost taste it.
    here is what I have so far on the calculate button:
     Private Sub BtnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalculate.Click
            'step 1 - get input value from user
            '   1a - get the value of A, or radius
            Dim NUDRadOrDimA As Integer
            Dim NudHeightOrB As Integer
            '   1b - get the value of B, or the height
            'step 2 - define the needed variables to the input values
            'step 3 - determine which radio button was selected
            If RdPythagorean.Checked Then
                System.Math.Sqrt(NUDRadOrDimA ^ 2 + NudHeightOrB ^ 2)
                'pythagorean Theorem calculation
                'A^2 + B^2 = the length of the angle in the triangle (C^2)
                '= pythagorean theorem
                TxtResults.Text = (NUDRadOrDimA ^ 2 + NudHeightOrB ^ 2)
            End If
            If RdCylinder.Checked Then
                'Cylinder volume calculation
                'pi * (radius^2) * height = volume of a cylinder
                '= cylinder volume
                TxtResults.Text = (3.14 * ((NUDRadOrDimA ^ 2) * NUDHeightOrB))
            End If
            'step 4 - calculate the value based on above
            'step 5 - display the output
        End Sub
    I appreciate any suggestions.

    Thank you
    Last edited by loquin; 08-06-09 at 19:47. Reason: add code tags for readability

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    well this doens't seem to beanythign to do with databases, so I suspect you will be better off asking this sort of question in the sister forum to this site programming talk.. its the last forum on the front page.

    however it looks to me as if you dont assign a value to the variables NUDRadOrDimA & NudHeightOrB. there is no reference I can see to numeric up and down controls you suggest in your question. so I'm guessing that is your problem.
    Last edited by healdem; 08-03-09 at 03:10.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2009
    thank you for the guideance. I am new to this stuff, forums as well as programming.

Posting Permissions

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