Wednesday, April 24, 2013

[VB.NET] Declaring Constants

Today I am going to show you how to declare constants in VB.NET.

We are going to be working with this example program today.


Module constantsNenum
   Sub Main()
      Const PI = 3.14149
      Dim radius, area As Single
      radius = 7
      area = PI * radius * radius
      Console.WriteLine("Area = " & Str(area))
      Console.ReadKey()
   End Sub
End Module
This program will show you basically how to declare constants.


Dim radius, area As Single
This line of code declares that radius and area should be Single numbers.


radius = 7
This basically says that radius = 7.


area = PI * radius * radius

This declares that the variable are is PI * radius * radius.

And then at the end this outputs the area :D

No comments:

Post a Comment