VB.Net Tutorial/Class Module/Const

Материал из VB Эксперт
Перейти к: навигация, поиск

Define Integer constant

<source lang="vbnet">Module Module1

   Sub Main( )
      Const FreezingPoint As Integer = 32 
      Const BoilingPoint As Integer = 212
      System.Console.WriteLine("Freezing point of water: {0}", FreezingPoint)
      System.Console.WriteLine("Boiling point of water: {0}", BoilingPoint)
   End Sub
End Module</source>
Freezing point of water: 32
Boiling point of water: 212

Use Const to define constant

<source lang="vbnet">Module Module1

   Sub Main()
       Const Pi = "3.1415926535"
       Console.WriteLine(Pi)
   End Sub

End Module</source>

3.1415926535