Public Class classpass2
Inherits Form
Private motdepasse As String = "123456789"
Event okpassword()
WithEvents mypassoword As New MaskedTextBox
WithEvents valid As New Button
Public Sub New()
Me.Height = 300
Me.Width = 300
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.StartPosition = FormStartPosition.Manual
valid.Enabled = False
valid.Text = "VALIDER"
mypassoword.PasswordChar = "*"c
mypassoword.Font = New Font("calibri", 12, FontStyle.Bold)
Me.Controls.Add(mypassoword)
Me.Controls.Add(valid)
mypassoword.Location = New Point(Me.Width \ 2 - mypassoword.Width \ 2, 10)
valid.Location = New Point(Me.Width \ 2 - valid.Width \ 2, mypassoword.Bottom + 10)
End Sub
Private Sub valid_MouseClick(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles valid.MouseClick
If mypassoword.Text = motdepasse Then
RaiseEvent okpassword()
Me.Dispose()
End If
End Sub
Private Sub mypassoword_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles mypassoword.KeyUp
If mypassoword.Text.Length = motdepasse.Length Then
valid.Enabled = True
Else
valid.Enabled = False
End If
End Sub
End Class
Public Class Form1
'on definit pass2
Private WithEvents pass2 As classpass2
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Pmail1.Visible = False Then 'ici je vérifie la condition
pass2 = New classpass2
pass2.Location = New Point(Me.Width \ 2 - pass2.Width \ 2, Me.Height \ 2 - pass2.Height \ 2)
pass2.ShowDialog()
Exit Sub 'Arrêter l'execution
End If
End Sub
Private Sub pass2_okpassword() Handles pass2.okpassword
'ici tu continues le password est correct
End Sub
End Class
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Form2.ShowDialog() MsgBox("on continue") End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Me.Hide() End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Form2.ShowDialog() If Form2.CheckBox1.Checked = True Then MsgBox("on continue") Else 'rien End If End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click If pass.Text = "123" Then CheckBox1.Checked = True 'C'EST ICI QUE JE SOUHAITE RENVOYER A L'EXECUTION DU FORM1 Me.pass.Text = "" Me.Hide() Else CheckBox1.Checked = False Me.pass.Text = "" Me.Hide() End If Me.Hide() End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question