Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Password Userform

Dear experts,

I want to create an userform with a textbox in which users will input a
password (e.g. PSSW1223). As usual, the characters input will not be shown
but by "********" instead. If the user inputs correctly, a dialogue box
appears stating the password is correct. If the password is incorrect, the
dialogue box will show the wording on the contrary. The user can have 3
trials at the maximum. Please advise what should the VBA code for the user
form. Please kindly advise.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,533
Default Password Userform

Hi
Setup at userform with a textbox and a command button.
First select TextBox1 and in the Properties window (F4), find 'PasswordChar'
and enter *

Then try this code and notice that the dim statement has to be inserted at
the very top of the userform module:

Dim Trial As Long

Private Sub CommandButton1_Click()
TitleStr = "Password check"
If Me.TextBox1.Value = "PSSW1223" Then
msg = MsgBox("Correct password", vbExclamation + vbOKOnly, TitleStr)
Me.Hide
'what to do when password is correct?
Else
Trial = Trial + 1
If Trial < 3 Then
msg = MsgBox("Wrong password, please try again", vbExclamation +
vbOKOnly, TitleStr)
Me.TextBox1.SetFocus
Else
msg = MsgBox("Wrong password, shutting down...", vbCritical +
vbOKOnly, TitleStr)
Unload Me
End If
End If
End Sub

Regards,
Per


"Freshman" skrev i meddelelsen
...
Dear experts,

I want to create an userform with a textbox in which users will input a
password (e.g. PSSW1223). As usual, the characters input will not be shown
but by "********" instead. If the user inputs correctly, a dialogue box
appears stating the password is correct. If the password is incorrect, the
dialogue box will show the wording on the contrary. The user can have 3
trials at the maximum. Please advise what should the VBA code for the user
form. Please kindly advise.

Thanks in advance.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password userform activate Moh Excel Discussion (Misc queries) 2 December 14th 07 09:01 AM
Password protected userform AOU Excel Discussion (Misc queries) 4 September 15th 07 04:48 PM
Userform password to show "xxxxxx" in the text box Ola2B Excel Discussion (Misc queries) 7 March 15th 07 02:52 PM
UserForm Password Ola2B Excel Discussion (Misc queries) 1 February 28th 07 02:25 PM
Password Userform help !!!! K1KKKA Excel Discussion (Misc queries) 4 January 10th 07 03:09 PM


All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"