Public Function Paskdag(datum As String) As String
Dim a As Long, b As Long, c As Long, D As Long, e As Long, f As Long, g As Long, h As Long, i As Long
Dim k As Long, l As Long, m As Long, eastermonth As String, p As Long, easterdate As String
Dim year As Long
year = CLng(Left(datum, 4))
a = year Mod 19
b = year / 100
c = year Mod 100
D = avrunda(b / 4)
e = b Mod 4
f = avrunda((b + 8) / 25)
g = avrunda((b - f + 1) / 3)
h = (19 * a + b - D - g + 15) Mod 30
i = avrunda(c / 4)
k = c Mod 4
l = (32 + 2 * e + 2 * i - h - k) Mod 7
m = avrunda((a + 11 * h + 22 * l) / 451)
eastermonth = avrunda((h + l - 7 * m + 114) / 31) '[3=Mars, 4=April]
p = (h + l - 7 * m + 114) Mod 31
easterdate = p + 1 '(Dag i månaden)
'Är datumet ensiffrigt?
If Len(easterdate) = 1 Then
easterdate = "0" & easterdate
End If
'Returnera datum
Paskdag = "0" & eastermonth & "-" & easterdate
End Function
Private Function avrunda(tal As Double) As Long
Dim utTal As String, dec As Boolean, strTal As String, k As Long, stopp As Long
utTal = tal
k = 1
stopp = Len(utTal)
For k = 1 To stopp
If Mid(utTal, k, 1) = "," Then
Exit For
Else
strTal = Left(utTal, k)
End If
Next k
avrunda = CLng(strTal)
End Function