Newbie: so am trying to figure out how to prompt the user for a # that represents a radius of some circle and place that # into a variable and use to calculate the area of the circle with the given radius. need to use a user=defined constant for the value TT thats used in calculation of the area and a bit later the volume.

prompt user for hgt value, using same radius, calculate volume of a cone having the radius entered above.

generate a msgbox to display
i.e. a cirlce with radius 27 has area 2,290.2191
a cone with radius 27 and height 13 has volume 9,924.2828

suggestions please....

Hey its quite simple.. First u add a textbox to ur form to input the radius.. also add a calculate button.. when u double click the calc button it'l go to the code part where a function will be generated that handles the button click.. now in this function you can access the value that was typed into the radius textbox by using "textbox_name.Text" and to convert it to an integer you can use the CInt function.. basically you'l hav a line saying Dim i as Integer=CInt(tb_radius.Text).

Now you can use the variable to do wat u like... same way for height etc. to display the answer you can use a label and set the text of the label by using label_ans.Text=12345..

Hope that helps :)

Public Class Form1

    Private Function GetAreaOfCircle(ByVal radius As Double) As Double
        Return Math.Round(Math.PI * Math.Pow(radius, 2), 9)
    End Function

    Private Function GetVolumeOfCone(ByVal radius As Double, ByVal height As Double) As Double
        Return Math.Round(0.3333333333 * GetAreaOfCircle(radius) * height, 9)
    End Function

    Private Sub ButtonCalculateAreaOfCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCalculateAreaOfCircle.Click
        If ValidateRadius(TextBoxRadius.Text) = False Then
            Exit Sub
        End If
        MsgBox(GetAreaOfCircle(CDbl(TextBoxRadius.Text)).ToString)
    End Sub

    Private Sub ButtonCalculateVolumeOfCone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonCalculateVolumeOfCone.Click
        If ValidateRadius(TextBoxRadius.Text) = False Then
            Exit Sub
        End If
        If ValidateHeight(TextBoxHeightOfCone.Text) = False Then
            Exit Sub
        End If
        MsgBox(GetVolumeOfCone(CDbl(TextBoxRadius.Text), CDbl(TextBoxHeightOfCone.Text)).ToString)
    End Sub

    Private Function ValidateRadius(ByVal radius As String) As Boolean
        If String.IsNullOrEmpty(radius) Then
            MsgBox("Enter a radius.")
            Return False
        End If
        If Not IsNumeric(radius) Then
            MsgBox("Radius must be numeric")
            Return False
        End If
        Return True
    End Function

    Private Function ValidateHeight(ByVal height As String) As Boolean
        If String.IsNullOrEmpty(height) Then
            MsgBox("Enter a height.")
            Return False
        End If
        If Not IsNumeric(height) Then
            MsgBox("Height must be numeric")
            Return False
        End If
        Return True
    End Function

End Class
This article has been dead for over six months. Start a new discussion instead.