Option Explicit
Private Sub chkPass_Click()
Dim a As Integer
a = FreeFile
'INIZIO PROCEDIMENTO PER GESTIRE LA CHECKBOX
Open App.Path & "\VerPass.dat" For Random As a
If chkPass.Value = 1 Then
Put a, 1, "1"
Else
Put a, 1, "0"
End If
Close a
'FINE PROCEDIMENTO PER GESTIRE LA CHECKBOX
End Sub
Private Sub cmdIndietro_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
On Error GoTo errore
'INIZIO PROCEDIMENTO DI INSERIMENTO PASSWORD
'Apro il file dove c'è la password
Dim a As Integer
a = FreeFile
'Se tutte le caselle di testo sono vuote
'si presume che l'utente abbia aperto la finestra
'solo per cambiare il segno di spunta
'quindi:--------------------------------
If txtVecchiaPass.Text = "" And txtNuovaPass.Text = "" And txtRipetiPass.Text = "" Then
Unload Me
Exit Sub
End If
'-------------------------------------
Open App.Path & "\pass.dat" For Random As a
Get a, 1, Password
'Se la casella di testo txtVecchiaPass è uguale
'al valore di default cioè 0000 OPPURE
'al valore contenuto nel file,
'E SE le ultime due caselle di testo sono identiche
'allora tutto OK, scrivo la nuova password
If txtVecchiaPass.Text = Password Then
If txtNuovaPass.Text = txtRipetiPass.Text Then
Password = txtNuovaPass.Text
Put a, 1, Password
MsgBox "Password modificata con successo", , "Password"
End If
Else
MsgBox "Si è verificato un errore, controlla di aver inserito" & _
" i dati correttamente.", vbExclamation, "ERRORE"
End If
Close a
'FINE PROCEDIMENTO DI INSERIMENTO PASSWORD
Unload Me
Exit Sub
errore:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
Dim a As Integer
Dim Valore As String
a = FreeFile
'Verifico se la checkbox deve essere spuntata o meno
Open App.Path & "\VerPass.dat" For Random As a
Get a, 1, Valore
If Valore = "1" Then
chkPass.Value = vbChecked
End If
Close a
End Sub