AW: CommandButton mit Passwortabfrage
29.11.2015 13:03:10
Sven
Hallo Matthias.
Das war wohl mein Grundfehler... Hatte das im Arbeitsblatt hinterlegt.
Der Code für die Userform sieht bei mir so aus:
Option Explicit
Dim bOk As Boolean
Private Sub cmdOK_Click()
bOk = True
Unload Me
End Sub
Public Function PasswortUebergabe(ByRef DasPasswort As String) As Boolean
Me.Show
If bOk Then
DasPasswort = txtPasswort
PasswortUebergabe = True
Else
PasswortUebergabe = False
End If
End Function
Private Sub cmdEscape_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
cmdOk.Default = True
cmdEscape.Cancel = True
txtPasswort.PasswordChar = "*"
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Me.Hide
DoEvents
End Sub
und im Modul so:
Option Explicit
Public Sub GetPasswort()
Dim sPass As String
If frmPasswort.PasswortUebergabe(sPass) Then
MsgBox sPass
Else
MsgBox "Abgebrochen"
End If
End Sub
Wo genau muss ich das da einfügen?
Habe gerade schon mehrere Varianten ausprobiert... Aber es geht nicht :-(
Gruß
Sven