Oppure

Loading
07/09/09 14:03
fusebyte
ho un ulteriore problema,se do la user pass esatta,ogni volta che apro me la richiede e non va bene,diventa scocciante per chiunque.
Quindi devo usare
SAVESETTING e GETSETTING

codice
Public x As Integer
'
Private Sub Form_Load()
x = 0
If Dir("C:\WINDOWS\System32\testo.txt") <> "" Then
    End
End If
End Sub

Private Sub cmdLogin_Click()
Dim a$, b$, C$, d$ ' il dollaro è STRINGA

C = GetSetting(APP.Title, "unformapp", a, Text1.Text)
d = GetSetting(APP.Title, "unformapp", b, Text2.Text)
  if x = 0 then ' obbligo a fare il controllo prima che x diventi 1 e chieda la pass
If c = a And d = b Then
fmrLogin.Visible = False
Form1.Visible = True
End If
 End if
a = "parapappa"
b = "123456"
 
 
If Text1.Text = a And Text2.Text = b Then
SaveSetting APP.Title, "unformapp", a, Text1.Text 'Salva user
SaveSetting APP.Title, "unformapp", b, Text2.Text 'Salva user
  Unload Me
  Sleep (2000)
Form1.Visible = True
   Else
Text1.Text = "": Text2.Text = ""
Form1.Visible = False
x = x + 1
'
If x = 3 Then
frmLogin.Visible = False
Unload Me
Open "C:\WINDOWS\System32\testo.txt" For Output As #1
    Print #1, "1"
      Close #1
   End If
  End If
End Sub


Intendevo fare questo:
Al primo avvio il GETSETTING e vuoto quindi la condizione non si verifica e passa oltre
Chiede USER e PASS che vengono subito memorizzate da SAVESETTING se esatte,senno' vale il discorso dei 3 tentativi e poi non si apre piu'.
Ora al secondo AVVIO ,GETSETTING dovrebbe trovare cio' che cerca e dare FALSE al frmLogin
e TRUE al FORM1 senza piu' chiedere la pass.
Mi da errore su GETSETTING,evidentemente sbaglio e credo sia nella costruzione del contemuto di GETSETTING e SAVESETTING.

Grazie anticipate per l'aiuto
Ciao
Ultima modifica effettuata da fusebyte 07/09/09 14:09
aaa
07/09/09 22:39
Bene, ho imparato ad usare le 2 funzioni. Posta l'errore e ti dò la soluzione =)

P.S = In quel codice c'è qualcosa che non mi convince, domani lo provo.
07/09/09 23:24
fusebyte
Dopo aver inserito user e pass ,scompare il frmLogin e mi da
Error Run-Time 5
chiamata di Routine o Argomento non Valido


Quindi come penso sbaglio nel costruire GETSETTING e SAVESETTING e chissa' che altro...:-)
Infatti ,premo DEBUG e
Private Sub cmdLogin_Click()
Dim a$, b$, C$, d$
C = GetSetting(APP.Title, "unformapp", a, Text1.Text) <---errore
d = GetSetting(APP.Title, "unformapp", b, Text2.Text)

Ciao
Ultima modifica effettuata da fusebyte 07/09/09 23:27
aaa
08/09/09 1:04
Private Sub cmdLogin_Click()
Dim a$, b$, C$, d$ ' il dollaro è STRINGA --> Grazie :D:D

C = GetSetting(APP.Title, "unformapp", "usr", Text1.Text) 'modifico i valori
d = GetSetting(APP.Title, "unformapp", "pw", Text2.Text)

a = "parapappa" 'questi vanno prima, o confronti c e d con due variabili vuote
b = "123456"

if x = 0 then
 If c = a And d = b Then

  fmrLogin.Visible = False
  Form1.Visible = True

  Exit Sub 'se non metti questa, fa comunque le operazioni relative a user e password

 End If
End if

 
 
If Text1.Text = a And Text2.Text = b Then

SaveSetting APP.Title, "unformapp", "usr", Text1.Text
SaveSetting APP.Title, "unformapp", "pw", Text2.Text

  Unload Me
  Sleep (2000)
Form1.Visible = True
   Else
Text1.Text = "": Text2.Text = ""
Form1.Visible = False
x = x + 1

If x = 3 Then
frmLogin.Visible = False
Unload Me
Open "C:\WINDOWS\System32\testo.txt" For Output As #1
    Print #1, "1"
      Close #1
   End If
  End If
End Sub


Sì, è proprio lì l'errore :)

Niente di preoccupante, comunque: Nel terzo argomento di GetSetting, togli la variabile e metti qualcosa tra "". Nel tuo codice, la variabile a assume un valore solo dopo la chiamata di GetSetting, il quale non può avere un argomento senza valore. Dammi retta, togli a e metti "quellochetiparebastachenonsiaunavariabile" :D

Cambia anche il secondo GetSetting e i SaveSetting, come da esempio... Ora dovrebbe funzionare :k:
Ultima modifica effettuata da 08/09/09 1:09
08/09/09 2:34
fusebyte
A te funziona?
A me continua a chiedere la pass,parlo della routine con user e pass esatte.
ffff...c'è sempre qualche cosa che ti deve far sbattere la testa.....
Ho controllato con REGEDIT il registro e le 2 chiavi usr e pw ci sono con i valori esatti.
Quindi il problema è il codice,forse ci sfugge qualcosa.

Ciao:-)
Ultima modifica effettuata da fusebyte 08/09/09 2:38
aaa
08/09/09 2:42
fusebyte
No ,aspetta ,se premo il tasto senza inserire niente il soft di apre.
Quindi funziona.
Faccio la prova del 9
Inserisco user pass sbagliate 1 volta sola,dovrebbe sovrascrivere le 2 key nel registro.
Provo a riaprire solo col tasto,non dovrebbe permetterlo.

Ti faccio sapere.Ciao
aaa
08/09/09 3:29
fusebyte
Vorrei fare solo una implementazione
SaveSetting APP.Title, "unformapp", "usr", 0 'modifico i valori
SaveSetting APP.Title, "unformapp", "pw", 0

Mi sono fatto un tasto click del genere per debuggare,azzero il registro e testo le funzionalita'.

Sai se è possibile controllare le 2 textbox user pass?
Intendo se qualcuno inserisce parole errate,si disabilita il tasto cmdLogin e si azzera il registro cosi torna il discorso dei 3 tentativi.
In pratica dovremmo leggere quello che scrive e confrontarlo prima che cliccki.

Dici è possibile?

Oppure piu semplicemente sai come disabilitare con un tasto il tasto cmdLogin?


Scusa ste richieste stravaganti ma sto pensando se c'è tutto o manca qualcosa.
Ciao
aaa
08/09/09 10:36
GrG
il codice di prima per i 3 tentativi si basava sul file... se hai cambiato idea e vuoi basarti sul registro si può fare, ma il codice va un pò cambiato...

per quanto riguarda disabilitare cmdLogin basta fare:
cmdLogin.enabled = false
aaa