Add a form called frmPassword. It will show modally.
Put a Public procedure in Form frmPassword.
frmPassword has a label for prompt, a textbox for entry and commands control array of OK and Cancel. Set textbox passwordchar to "*".
code:--------------------------------------------------------------------------------
' in Main Form
strPassword = frmpassword.GetPassword("Enter your password"
if Len(strPassword) = 0 then ' no entry
'........
else
'.... password entered
End if
'frmPassword
Option Explicit
Public Function GetPassword(Optional ByVal strPrompt As String = "" As String
lblPassword = strPrompt
Me.Show vbModal ' Modal form, waits for Hide, visible=false
GetPassword = txtPassword
Unload Me
End Function
Private Sub cmdOKCancel_Click(Index As Integer)
If cmdOKCancel(1).Value Then ' Cancelled
txtPassword = ""
End If
Me.Hide ' Release modal
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmPassword = Nothing ' Release everything
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.