ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to create a constant using const keyword

Here, we are going to learn how to create a constant using const keyword in VB.Net?
Submitted by Nidhi, on December 20, 2020

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 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 »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.