' Visual Basic 2008 9.0 .NET Examples - Module Variables - Procedures and Functions : Module Example1 Dim sum As Integer ' (1) Sub Main() Dim value1 As Integer = 5 Dim value2 As Integer = 10 ' MakeSum(value1, value2) ' Console.WriteLine(sum) ' (2) ' Console.ReadLine() End Sub Sub MakeSum(ByVal value1 As Integer, ByVal value2 As Integer) sum = value1 + value2 ' (3) End Sub End Module Module Example2 Dim x As Integer = 1 ' (1) Sub Main() Test1() ' Dim x As Integer = 2 ' (2) Console.WriteLine(x) ' (3) ' Test2(x) ' (4) ' Console.ReadLine() End Sub Sub Test1() Console.WriteLine(x) ' (5) End Sub Sub Test2(ByVal x As Integer) ' (6) x += 1 ' (7) Console.WriteLine(x) ' (8) End Sub End Module Module Exercise1Task Dim test As Integer Sub Main() Test1() Test2() ' Console.ReadLine() End Sub Sub Test1() Dim test As Integer = 1 Test3(test) End Sub Sub Test2() test = 2 Test3(test) End Sub Sub Test3(ByVal test As Integer) test += test Console.WriteLine(test) End Sub End Module Module Exercise2Task Dim a As Integer = 1 Sub Main() Dim a As Integer Dim b As Integer Dim c As Integer Dim d As Integer Dim e As Integer ' a += 2 ' Test(a, b + e, c + 1, d) ' Console.WriteLine(a) Console.WriteLine(b) Console.WriteLine(c) Console.WriteLine(d) Console.WriteLine(e) ' Console.ReadLine() End Sub Sub Test(ByVal b As Integer, ByRef c As Integer, _ ByVal d As Integer, ByRef e As Integer) b += a c += b d += c e += d End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.