bisestile2

 

Option Explicit



Private Function bisestile(anno As Integer) As Boolean
Dim d As Date
d = DateSerial(anno, 2, 28)
d = d + 1
If Month(d) = 2 Then
bisestile = True
Else
bisestile = False
End If
CommandButton1.SetFocus
End Function

Private Sub CommandButton1_Click()
Dim anno As Integer
anno = 1988
Lista.AddItem (anno)
If (bisestile(anno)) Then
Lista.AddItem ("bisestile")
Else
Lista.AddItem ("non bisestile")
End If
End Sub

Private Sub CommandButton2_Click()
Dim x As Date
Dim y As Date

x = #12:00:00 PM#
y = #1:00:00 PM#
Lista2.AddItem (x)
Lista2.AddItem (y)
Lista2.AddItem (secondi(x, y))
End Sub




Public Function secondi(inizio As Date, fine As Date) As Long
Dim differenza As Double
Dim risultato As Double
differenza = (fine - inizio)
risultato = (differenza / 1.15740740741499E-05)
secondi = risultato

End Function
Public Function minuti(inizio As Date, fine As Date) As Long
Dim differenza As Double
Dim risultato As Double
differenza = (fine - inizio)
risultato = (differenza / 0.000694444445)
minuti = risultato

End Function

Private Sub CommandButton3_Click()
Lista2.Clear
End Sub

Private Sub CommandButton4_Click()
Dim x As Date
Dim y As Date
x = #10:00:00 AM#
y = #2:00:00 PM#
Lista2.AddItem (x)
Lista2.AddItem (y)
Lista2.AddItem (minuti(x, y))
End Sub

Private Sub CommandButton5_Click()
Dim anno As Integer
anno = 1987
Lista.AddItem (anno)
If (bisestile(anno)) Then
Lista.AddItem ("bisestile")
Else
Lista.AddItem ("non bisestile")
End If
End Sub

Private Sub UserForm_Click()

End Sub