VB.Net Tutorial/Language Basics/static
Call static method
<source lang="vbnet">Option Strict On Public Module CallStaticMethod
Public Sub Main() Console.WriteLine(Greeting.SayHello()) End Sub
End Module Public Class Greeting
Public Shared Function SayHello() As String Return "And a top of the morning to you!" End Function
End Class</source>
And a top of the morning to you!
static Variable
<source lang="vbnet">Option Strict On Public Module Test
Public Sub Main() For loopCtr As Integer = 1 to 10 Console.WriteLine(Invocations()) Next End Sub Private Function Invocations() As Integer Static i As Integer i += 1 Return i End Function
End Module</source>
1 2 3 4 5 6 7 8 9 10