Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Input Box

Status
Not open for further replies.

lookE

IS-IT--Management
Sep 28, 2002
23
US
Some help please?

I have an input box where the user will be typing in a password. How can I get the characters to appear encrypted (i.e. *****) as the user is typing? Thank you.

 
Do your own form named frmPassword.

Dim frmPass as frmPassword
Dim strPassWord As String
.....
Set frmPass = New frmPassWord
strPassWord = frmPass.GetPassword
if Len(strPassWord) then
....cancel out
End if


Put a label, textBox, and two buttons labeld OK and Cancel on the form.

The form contains one function and two subs.

Public Function GetPassword(Optional ByVal Prompt As String = "") As String
lblPassword = Prompt
txtPassword.Passwordchar="*"
Me.Show vbModal ' Modal form, wait for Hide
GetPassword = txtPassword
Unload Me
End Function

Private Sub cmdOK_Click()
Me.Hide ' Release modal
End Sub
Private Sub cmdCancel_Click()
txtPassword = ""
Me.Hide ' Release modal
End Sub

Then in the calling form get the password with

Dim frmPass as frmPassword
Dim strPassWord As String
.....
Set frmPass = New frmPassWord
strPassWord = frmPass.GetPassword("Enter your password")
if Len(strPassWord) then
....cancel out ' nothing entered
End if


Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
hi
put ur text field in the form, and then go to the property window of the this textfield. there u would find a "passwordchar", putin ur desired character used as password character like *.
now on the text property, delete text1.
n thatz it, easy :)
bye
bilal
bilalbusy@yahoo.com
 
He said "input box" so I assumed he meant InputBox function, which does not have a password capability.

Also, an addition. On the frmPassword, make ControlBox, MinButton, and MaxButton = false at design-time. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top