' Visual Basic 2008 9.0 .NET Examples - Static Variables - Procedures and Functions : Module Example1 Sub Main() Test1() Test1() Test1() ' Test2() Test2() Test2() ' Console.ReadLine() End Sub Sub Test1() Static x As Integer x += 1 Console.WriteLine(x) End Sub Sub Test2() Static x As Integer = 10 x += 1 Console.WriteLine(x) End Sub End Module Module Example2 Sub Main() Test() Test() Test() ' Console.ReadLine() End Sub Sub Test() Static firstExecution As Boolean = True If firstExecution Then Console.WriteLine("First execution of Test.") firstExecution = False Else Console.WriteLine("Not the first execution of Test.") End If End Sub End Module Module Exercise1Task Sub Main() Test1() Test1() ' Console.ReadLine() End Sub Sub Test1() Static t1 As Integer = 10 t1 += 1 Test2(t1) Test2(t1) End Sub Sub Test2(ByVal t2 As Integer) Static t3 As Integer = 20 t3 += t2 Console.WriteLine(t3) End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.