Oplossing oefeningen functieprocedures

Public Function MaandDag(dtmDatum As Date) As String
MaandDag = Format(dtmDatum, "mm-dd")
End Function

Public Function Leeftijd(geboortedatum As Date)
Dim dtmHulp As Date
dtmHulp = DateSerial(Year(Now()), Month(geboortedatum), Day(geboortedatum))
If dtmHulp > Date Then
   Leeftijd = Year(Date) - Year(geboortedatum) - 1
Else
   Leeftijd = Year(Date) - Year(geboortedatum)
End If
End Function


Public Function Sorteerformaat(Naam As String) As String
Dim intTeller As Integer
Sorteerformaat = ""
For intTeller = 1 To Len(Naam)
   Select Case Mid(Naam, intTeller, 1)
     Case "A" To "Z", "a" To "z"
         Sorteerformaat = Sorteerformaat + UCase(Mid(Naam, intTeller, 1))
     Case "é", "è", "ë", "ê"
         Sorteerformaat = Sorteerformaat + "E"
    Case "ç"
         Sorteerformaat = Sorteerformaat + "C"
   End Select
Next
End Function

terug


Public Function Palindroom(woord As String) As Boolean
Dim strOmgekeerd As String
Dim intTeller As Integer
Dim blnOK As Boolean
If Len(woord) > 0 Then
   blnOK = True
   intTeller = 1
   Do
      If Mid(woord, intTeller, 1) = Mid(woord, Len(woord) - intTeller + 1, 1) Then
         intTeller = intTeller + 1
      Else
         blnOK = False
      End If
   Loop Until blnOK = False Or intTeller >= Len(woord) / 2
   Palindroom = blnOK
Else
   Palindroom = True
End If
End Function


Public Function KleinsteVan3(a, b, c As Single) As Single
If a < b Then
   If a < c Then
      KleinsteVan3 = a
   Else
      KleinsteVan3 = c
   End If
Else
   If b < c Then
      KleinsteVan3 = b
   Else
      KleinsteVan3 = c
   End If
End If
End Function


terug