Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Agenda - ageDifferenza.frm

ageDifferenza.frm

Caricato da: Antometal
Scarica il programma completo

  1. Option Explicit
  2.  
  3. Private Sub ControlloData(Giorno As TextBox)
  4.     If IsDate(Giorno) = False Then
  5.         MsgBox "Errore, tipo non corrispondente" & vbCrLf & "Inserire la data in formato:   gg\mm\aaaa", vbCritical
  6.         Giorno.Text = Date
  7.         Giorno.SelStart = 0
  8.         Giorno.SelLength = Len(Giorno)
  9.         Giorno.SetFocus
  10.     End If
  11. End Sub
  12.  
  13. Private Function GiornoSettimana(Giorno As Date) As String
  14.     If Weekday(Giorno) = 1 Then GiornoSettimana = "domenica"
  15.     If Weekday(Giorno) = 2 Then GiornoSettimana = "lunedì"
  16.     If Weekday(Giorno) = 3 Then GiornoSettimana = "martedì"
  17.     If Weekday(Giorno) = 4 Then GiornoSettimana = "mercoledì"
  18.     If Weekday(Giorno) = 5 Then GiornoSettimana = "giovedì"
  19.     If Weekday(Giorno) = 6 Then GiornoSettimana = "venerdì"
  20.     If Weekday(Giorno) = 7 Then GiornoSettimana = "sabato"
  21. End Function
  22.  
  23. Private Sub Form_Load()
  24. picOrologio.Scale (-4500, 4500)-(4500, -4500)
  25. txtData1.Text = Date
  26. txtData2.Text = Date
  27. lblDifferenza.Caption = ""
  28. End Sub
  29.  
  30. Private Sub optTempo_Click(Index As Integer)
  31. Dim Anni As Integer
  32. Dim Mesi As Long
  33. Dim Giorni As Long
  34.     If IsDate(txtData1) = True And IsDate(txtData2) = True Then
  35.         Giorni = Abs(DateDiff("d", txtData1, txtData2))
  36.         Mesi = Abs(DateDiff("m", txtData1, txtData2))
  37.         Anni = Mesi / 12
  38.         lblData1.Caption = GiornoSettimana(txtData1)
  39.         lblData2.Caption = GiornoSettimana(txtData2)
  40.             If Index = 0 Then lblDifferenza.Caption = "Tra le 2 date intercorrono " & Giorni & " giorni"
  41.             If Index = 0 And Giorni = 1 Then lblDifferenza.Caption = "Tra le 2 date intercorre un giorno"
  42.             If Index = 1 Then lblDifferenza.Caption = "Tra le 2 date intercorrono " & Mesi & " mesi"
  43.             If Index = 1 And Mesi = 1 Then lblDifferenza.Caption = "Tra le 2 date intercorre un mese"
  44.             If Index = 2 Then lblDifferenza.Caption = "Tra le 2 date intercorrono " & Anni & " anni"
  45.             If Index = 2 And Anni = 1 Then lblDifferenza.Caption = "Tra le 2 data intercorre un anno"
  46.     End If
  47.     If IsDate(txtData1) = True Then ControlloData txtData2
  48. ControlloData txtData1
  49. End Sub
  50.  
  51. Private Sub tmOrologio_Timer()
  52. Dim Sec, Min, Ore As Integer
  53. Const Pi As Double = 3.14159
  54. Sec = Second(Time)
  55. Min = Minute(Time)
  56. Ore = Hour(Time)
  57. lnSec.X2 = Sin(Sec * 6 * Pi / 180) * 4000
  58. lnSec.Y2 = Cos(Sec * 6 * Pi / 180) * 4000
  59. lnMin.X2 = Sin((Min + Sec / 60) * 6 * Pi / 180) * 3500
  60. lnMin.Y2 = Cos((Min + Sec / 60) * 6 * Pi / 180) * 3500
  61. lnOre.X2 = Sin((Ore + Min / 60) * 30 * Pi / 180) * 3000
  62. lnOre.Y2 = Cos((Ore + Min / 60) * 30 * Pi / 180) * 3000
  63. lblOra.Caption = Time
  64. lblOraAmPm.Caption = Format(Time, "h:nn:ss AM/PM")
  65. End Sub
  66.  
  67. Private Sub txtData1_Change()
  68. optTempo(0).Value = False
  69. optTempo(1).Value = False
  70. optTempo(2).Value = False
  71. lblDifferenza.Caption = ""
  72. End Sub
  73.  
  74. Private Sub txtData2_Change()
  75. txtData1_Change
  76. End Sub