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
Spegnieto automatico - Segnimento Automatico.frm

Segnimento Automatico.frm

Caricato da: Antometal
Scarica il programma completo

  1. Option Explicit
  2. Public Spegnimento As Boolean
  3. Public Differenza As Integer
  4. Public Data As String
  5. Public Ora As String
  6. Public Ore As Integer
  7. Public Min As Integer
  8. Public Sec As Integer
  9.  
  10. Private Function Differenza_Ore(Ore As Integer, Min As Integer, Sec As Integer)
  11. Sec = Sec - Second(Time)
  12.     If Sec < 0 And Min > 0 Then
  13.         Sec = Sec + 60
  14.         Min = Min - 1
  15.     End If
  16. Min = Min - Minute(Time)
  17.     If Min < 0 And Ore > 0 Then
  18.         Min = Min + 60
  19.         Ore = Ore - 1
  20.     End If
  21. Ore = Ore - Hour(Time)
  22. Differenza_Ore = Ore & "." & Min & "." & Sec
  23. End Function
  24.  
  25. Private Sub Controllo(Oggetto As TextBox, LimiteInferiore As Integer, LimiteSuperiore As Integer)
  26.     If IsNumeric(Oggetto) = False Then GoTo NumerO
  27.     If Oggetto > LimiteSuperiore Or Oggetto < LimiteInferiore Then GoTo SbagliatO
  28.  
  29. Exit Sub
  30. NumerO:
  31. MsgBox "Errore, inserisci un valore numerico", vbCritical
  32. Form_Load
  33. Exit Sub
  34. SbagliatO:
  35. MsgBox "Inserisci un numero maggiore o uguale a " & LimiteInferiore & " e minore o uguale a " & LimiteSuperiore, vbExclamation
  36. Form_Load
  37. End Sub
  38.  
  39. Private Sub chkAbilita_Click()
  40. cmdAdesso.Enabled = CBool(chkAbilita)
  41. End Sub
  42.  
  43. Private Sub cmdAdesso_Click()
  44. Tempo.Enabled = False
  45. Shutdown EWX_POWEROFF
  46. Unload Me
  47. End
  48. End Sub
  49.  
  50. Private Sub cmdAttiva_Click()
  51. Dim I As Integer
  52. Data = txtTime(0) & "/" & txtTime(1) & "/" & txtTime(2)
  53.     If IsDate(Data) = False Then
  54.         MsgBox "Errore, data inserita non valida", vbExclamation
  55.         Form_Load
  56.     End If
  57.    
  58. Data = txtTime(0) & "/" & txtTime(1) & "/" & txtTime(2)
  59. Differenza = Abs(DateDiff("d", Data, Date))
  60.  
  61.     If Differenza = 0 And Data <= Date Then GoTo Data_Grande
  62.     If Differenza > 0 Then
  63.         Controllo txtTime(3), 0, 23
  64.         Controllo txtTime(4), 0, 59
  65.         Controllo txtTime(5), 0, 59
  66.     End If
  67.  
  68. Ora = txtTime(3) & "." & txtTime(4) & "." & txtTime(5)
  69.    
  70.     If Date <= Data Or Ora > Time Then
  71.         Tempo.Enabled = True
  72.         cmdStop_Avvia.Enabled = True
  73.         Spegnimento = True
  74.             For I = 0 To 5
  75.                 txtTime(I).Enabled = False
  76.             Next I
  77.     End If
  78.  
  79. Exit Sub
  80. Data_Grande:
  81. MsgBox "Errore, inserire un orario valido", vbExclamation
  82. Form_Load
  83. End Sub
  84.  
  85. Private Sub cmdReset_Click()
  86. Dim Risposta As VbMsgBoxResult
  87.     If Spegnimento = True Then Risposta = MsgBox("Sicuro di voler annullare il countdown?", vbQuestion + vbYesNo)
  88.     If Risposta = vbYes Or Spegnimento = False Then Form_Load
  89. End Sub
  90.  
  91. Private Sub cmdStop_Avvia_Click()
  92. Tempo.Enabled = Not Tempo.Enabled
  93.     If Tempo.Enabled = False Then cmdStop_Avvia.Caption = "A&vvia"
  94.     If Tempo.Enabled = True Then cmdStop_Avvia.Caption = "Sto&p"
  95.     If Spegnimento = False Then End
  96. End Sub
  97.  
  98. Private Sub cmdEsci_Click()
  99. Dim Risposta As VbMsgBoxResult
  100.     If Tempo.Enabled = True Then Risposta = MsgBox("Sicuro di voler terminare il processo?", vbQuestion + vbYesNo)
  101.     If Risposta = vbYes Or Tempo.Enabled = False Then End
  102. End Sub
  103.  
  104. Private Sub Form_Load()
  105. Dim I As Integer
  106. Control_windows
  107.     For I = 0 To 5
  108.         txtTime(I).Enabled = True
  109.     Next I
  110. cmdAttiva.Caption = "&Spegni pc all' ora stabilita"
  111. cmdStop_Avvia.Enabled = False
  112. cmdStop_Avvia.Caption = "Sto&p"
  113. Tempo.Enabled = False
  114. Spegnimento = False
  115. txtTime(0) = Day(Date)
  116. txtTime(1) = Month(Date)
  117. txtTime(2) = Year(Date)
  118. txtTime(3) = 23
  119. txtTime(4) = 59
  120. txtTime(5) = 59
  121. chkAbilita_Click
  122. End Sub
  123.  
  124. Private Sub Form_Unload(Cancel As Integer)
  125. Cancel = 1
  126. End Sub
  127.  
  128. Private Sub Tempo_Timer()
  129. Dim DifferenzaORE As String
  130. DifferenzaORE = Differenza_Ore(txtTime(3) + Differenza * 24, txtTime(4), txtTime(5))
  131. cmdAttiva.Caption = "Tempo rimanente: " & vbCrLf & vbCrLf & DifferenzaORE
  132.     If DifferenzaORE = "0.0.0" Then cmdAdesso_Click
  133. End Sub
  134.  
  135. Private Sub txtTime_GotFocus(Index As Integer)
  136. txtTime(Index).SelStart = 0
  137. txtTime(Index).SelLength = Len(txtTime(Index))
  138. txtTime(Index).SetFocus
  139. End Sub