Home >>VB.Net Programs >VB.Net program to calculate the area of the rectangle
Here, we can read from the user the length of the rectangle value, and then measure the rectangle area. The formula for the rectangle's area is given below:
Area = length * breadth
Program :
Below is the source code to calculate the area of the rectangle. The program given is compiled and successfully executed.
Example
Module Module1
Sub Main()
Dim length As Single = 0.0F
Dim breadth As Single = 0.0F
Dim area As Single = 0.0F
Console.Write("Enter the length of rectangle: ")
length = Single.Parse(Console.ReadLine())
Console.Write("Enter the breadth of rectangle: ")
breadth = Single.Parse(Console.ReadLine())
area = length * breadth
Console.WriteLine("Area of ractangle: {0}", area)
End Sub
End Module
Explanation:
We created a Module1 module in the program above that contains the Main() method. We generated three local variables, length, breadth, and area that are initialized with 0.0F in the Main() method. After that, we read from the user the importance of length and breadth.
area = length * breadth
Here, we calculated the rectangle area, and then we printed the area value on the console screen.