VB.Net Tutorial/Class Module/Public

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

Public Const

Imports System
Module MyTest
  Sub Main()
    Console.WriteLine(Counter.MIN_COUNT)
    Console.WriteLine(Counter.MAX_COUNT)
    Dim input As Integer = 100
    if input < Counter.MIN_COUNT or _
       Input > Counter.MAX_COUNT Then
      Console.WriteLine("Value is out of acceptable range!")
    Else
      Console.WriteLine("The value " & input.ToString() & _
                        " is acceptable!")
    End If
    
  End Sub
End Module
Public Class Counter
  Public Const MAX_COUNT As Integer = 500
  Public Const MIN_COUNT As Integer = 100
End Class
100
500
The value 100 is acceptable!

Public members are available to anything that can instantiate this type

Public Class SomeClassInMyAssembly
    
    Public vPublic As Integer
End Class