' Visual Basic 2008 9.0 .NET Examples - Method Overloading - Procedures and Functions : Module Example1 Sub Main() Dim value1 As Integer = 5 ShowDouble(value1) ' (1) ' Dim value2 As String = "test" ShowDouble(value2) ' (2) ' Console.ReadLine() End Sub Sub ShowDouble(ByVal value As Integer) ' (1) Console.WriteLine(value * 2) End Sub Sub ShowDouble(ByVal word As String) ' (2) Console.WriteLine(word & word) End Sub End Module Module Example2 Sub Main() Console.WriteLine(GetSum(1, 2)) Console.WriteLine(GetSum(1, 2, 3)) Console.WriteLine(GetSum(1, 2, 3, 4)) ' Console.ReadLine() End Sub Function GetSum(ByVal value1 As Integer, _ ByVal value2 As Integer) As Integer GetSum = value1 + value2 End Function Function GetSum(ByVal value1 As Integer, _ ByVal value2 As Integer, _ ByVal value3 As Integer) As Integer GetSum = value1 + value2 + value3 End Function Function GetSum(ByVal value1 As Integer, _ ByVal value2 As Integer, _ ByVal value3 As Integer, _ ByVal value4 As Integer) As Integer GetSum = value1 + value2 + value3 + value4 End Function End Module Module Exercise1Task Sub Main() 'Console.WriteLine(GetCombination("abc", "def")) 'Console.WriteLine(GetCombination(1, 2)) 'Console.WriteLine(GetCombination(True, True)) 'Console.WriteLine(GetCombination(True, False)) 'Console.WriteLine(GetCombination(False, True)) 'Console.WriteLine(GetCombination(False, False)) ' Console.ReadLine() End Sub End Module Module Exercise1Solution Sub Main() Console.WriteLine(GetCombination("abc", "def")) Console.WriteLine(GetCombination(1, 2)) Console.WriteLine(GetCombination(True, True)) Console.WriteLine(GetCombination(True, False)) Console.WriteLine(GetCombination(False, True)) Console.WriteLine(GetCombination(False, False)) ' Console.ReadLine() End Sub Function GetCombination(ByVal value1 As String, _ ByVal value2 As String) As String GetCombination = value1 & value2 End Function Function GetCombination(ByVal value1 As Integer, _ ByVal value2 As Integer) As Integer GetCombination = value1 + value2 End Function Function GetCombination(ByVal value1 As Boolean, _ ByVal value2 As Boolean) As Boolean GetCombination = value1 AndAlso value2 End Function End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.