'Visual Basic 2010 Method Overloading Procedures en Functies 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 ExerciseTask Sub Main() Console.WriteLine(ExerciseSolution.GetCombination("abc", "def")) Console.WriteLine(ExerciseSolution.GetCombination(1, 2)) Console.WriteLine(ExerciseSolution.GetCombination(True, True)) Console.WriteLine(ExerciseSolution.GetCombination(True, False)) Console.WriteLine(ExerciseSolution.GetCombination(False, True)) Console.WriteLine(ExerciseSolution.GetCombination(False, False)) ' Console.ReadLine() End Sub End Module Module ExerciseSolution 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 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2011 - Alle rechten voorbehouden.