×

VB.Net Programs

VB.Net program to create a constant using const keyword

By Nidhi Last Updated : October 13, 2024

How to create a constant in VB.Net?

Here, we will create a constant PI with the value 3.14, and then we will calculate the Area Of the Circle, and print the result on the console screen.

Program/Source Code:

The source code to create a constant using the const keyword is given below. The given program is compiled and executed successfully.

VB.Net code to create a constant using const keyword

'VB.Net program to create a constant using const keyword.

Module Module1
    Sub Main()
        Const PI As Single = 3.14

        Dim AreaOfCircle As Single = 0
        Dim Radius As Single = 5

        AreaOfCircle = PI * Radius * Radius

        Console.WriteLine("Area of circle is: " & AreaOfCircle)
    End Sub
End Module

Output:

Area of circle is: 78.5
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1. Here, we created a constant PI, which is initialized with 3.14, and we created three variables to calculate the area of the circle. At last, we printed the calculated area of the circle on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.