Gruppe
Dialog
Bereich
TextBox
Thema
Paßwortabfrage mit UserForm
Problem
Wie kann ich über eine UserForm ein Paßwort abfragen und je nach Wahrheitsgehalt der Antwort die Steuerung vornehmen? Das Paßwort darf nicht angezeigt werden.
Lösung
Geben Sie den nachfolgenden Code in das Klassenmodul der UserForm ein.
ClassModule: frmPasswort
Private Sub cmdAbbrechen_Click()
MsgBox "Kein Zugang!"
Unload Me
End Sub
Private Sub cmdOK_Click()
If txtPasswort.Text = "Paßwort" Then
MsgBox "Alles klar!"
Unload Me
Else
MsgBox "War wohl nix!"
txtPasswort.Text = ""
txtPasswort.SetFocus
End If
End Sub
Private Sub UserForm_Initialize()
txtPasswort.SetFocus
End Sub
StandardModule: basMain
Sub CallForm()
frmPasswort.Show
End Sub