﻿'Visual Basic 2012 Inleiding in Functies Procedures en Functies Module Exercise2Solution Sub Main() Console.WriteLine(IsLeapYear(1900)) Console.WriteLine(IsLeapYear(1996)) Console.WriteLine(IsLeapYear(2000)) Console.WriteLine() Console.WriteLine(GetDaysFebruary(1900)) Console.WriteLine(GetDaysFebruary(1996)) Console.WriteLine(GetDaysFebruary(2000)) Console.WriteLine() Console.WriteLine(GetDays(1900, 2)) Console.WriteLine(GetDays(1996, 2)) Console.WriteLine(GetDays(2000, 2)) Console.WriteLine() Console.WriteLine(GetDays(1900, 3)) Console.WriteLine(GetDays(1996, 3)) Console.WriteLine(GetDays(2000, 3)) ' Console.ReadLine() End Sub Function IsLeapYear(ByVal year As Integer) As Boolean If year Mod 4 = 0 AndAlso year Mod 100 <> 0 OrElse _ year Mod 400 = 0 Then IsLeapYear = True End Function Function GetDaysFebruary(ByVal year As Integer) As Integer GetDaysFebruary = 28 If IsLeapYear(year) Then GetDaysFebruary = 29 End Function Function GetDays(ByVal year As Integer, ByVal month As Integer) As Integer If month = 2 Then GetDays = GetDaysFebruary(year) Else Dim days As Integer() = _ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} GetDays = days(month - 1) End If End Function End Module 'Bezoek www.vbvoorbeelden.be voor meer Visual Basic voorbeelden. 'Copyright - De Wolf / vbvoorbeelden - 2003-2012 - Alle rechten voorbehouden.