Monday, May 17, 2021

Area of the Rectangle in VB.NET

 Machine Problem

Write a program that will ask the user to give a radius of a circle and the program will compute

the area of the circle.

Use the following formula below.

area = (3.14 * radius * radius)

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com







Program Listing

' Area of the Rectangle in VB.NET

' Prof. Jake Rodriguez Pomperada, MAED-IT, MIT

' www.jakerpomperada.com  and www.jakerpomperada.blogspot.com

' jakerpomperada@gmail.com

' Bacolod City, Negros Occidental Philippines

' May 16, 2021   Sunday  1:10 PM


Public Class Form1

    'Declaring constant value of PI of the circle

    Public Const PI = 3.14


    ' Compute Button

    Private Sub btnCompute_Click(sender As Object, e As EventArgs) Handles btnCompute.Click

        Dim radius As Single = 0.0F

        Dim area As Single = 0.0F

        Dim radius_value As String


        radius_value = txtRadius.Text


        If radius_value = "" Or IsNumeric(radius_value) = False Then

            MessageBox.Show("Please enter a radius value.")

            txtRadius.Focus()

        Else

            area = PI * Val(radius_value) * Val(radius_value)

            txtArea.Text = area.ToString("#####.##")

            txtArea.ReadOnly = True

        End If


    End Sub

    ' Clear Button

    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click

        txtRadius.Text = ""

        txtArea.Text = ""

        txtRadius.Focus()

    End Sub


    Private Sub btnQuit_Click(sender As Object, e As EventArgs) Handles btnQuit.Click

        Dim result = MessageBox.Show(" Are you sure you want to quit the program?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)

        If result = DialogResult.Yes Then

            Me.Close()

        Else

            Me.Show()

            txtRadius.Text = ""

            txtArea.Text = ""

            txtRadius.Focus()

        End If

    End Sub

End Class


No comments:

Post a Comment