Option Explicit
Dim lConta As Long
Dim X As Long
Private Sub cmdOrganizza_Click()
On Error GoTo errore
Timer1.Enabled = True
txtTimer.Locked = True
lConta = txtTimer.Text
Exit Sub
errore:
MsgBox Err.Description, vbCritical, "ERRORE"
End
End Sub
Private Sub Command1_Click()
Timer1.Enabled = False
txtTimer.Locked = False
End Sub
Private Sub Form_Load()
lConta = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
MsgBox "Creato da Roberto VB"
End
End Sub
Private Sub optShutdown_Click(Index As Integer)
Select Case Index
Case 0
txtValore.Text = "0"
Case 1
txtValore.Text = "1"
Case 2
txtValore.Text = "2"
Case 3
txtValore.Text = "4"
End Select
End Sub
Private Sub Timer1_Timer()
lConta = lConta - 1
lblTimer.Caption = lConta
'Se lConta è uguale a 0 allora spegne o riavvia il pc
If lConta <= 0 Then
Timer1.Enabled = False
X = ExitWindowsEx(txtValore.Text, 0&)
End If
End Sub