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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Code 1

Status
Not open for further replies.

APElliott

Technical User
Jul 9, 2002
165
GB
Hello,

I've found and altered the below code from a previous thread and wondered if there is a way of formatting the text that you enter for the password.

Thanks Andrew

mPass = InputBox("Enter password")
If mPass = "1234" Then
Sheets("Coins").Visible = True
Sheets("Coins Report").Visible = True
Else
MsgBox "You Do Not Have Viewing Rights!"
End If
 
As far as I know, the INPUTBOX can not hide anything placed in it. You will need to create your own form, a a textbox and choose Password from the properties page.

--MiggyD
 
Hi Andrew
What do you mean by formatting the text?
If you want to ensure that whatever is entered into a input box is checked against a password that is in lower case whether entered in upper or lower case you could use

if lcase(mpass) = "pword" then

If you mean you want a character to appear when the password is typed then you will have to create a form with a textbox. You can then set the password character property of the textbox to show any char you like.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Hello,

Looks like I'll have to create a Textbox:

To explain a bit better if the password is 1234 then as it is type I'd like to see ****.

Cheers,

Andrew
 
Yep, you'll have to create your own form for that procedure. If you plan on using that form constantly, I'd suggest you make it in a class module.

Good Luck,
--MiggyD
 
Cheers Steve,

Could you explain a bit further though - I'm a bit of a muppet!

Thanks,

Andrew
 
HI Andrew,

Steve means that you have to change the TextBox's PasswordChar property to "*". This way, when any text is entered into your TextBox, it will appear as asterisks only 1234 will read ****.

I hope this expalins it better for you.



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Cheers Mike,

I've found that now!

I'm really struggling with the code though - I thought it would be the same as above, but I'm lost.

I've created a form called ResourceDatabase. It's got the textbox on it for the password to be typed and an OK command button along with a cancel button.

Could you please help with the code.

Thanks Andrew.

PS How the hell do you get the Smiley's to work?



 
I had the same question with the smileys! [blush]

Before you submit a post, you can also preview it. below your post (while previewing it) you will see this text:

Use TGML (Tecumseh Group Mark-up Language) to format your posts to bold, underline, indent, color, and cursive your text. See examples below. Click Here for the full list of TGML tags and click Here for the full list of Emoticons/Smileys

Within that text are two links that give you tips on how and what to use for formatting and smiley, just try not to overdo it.

Have fun,

I will get back to you in a jif on the password code! :)



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Hi Andrew,

Here is your Password code.

Paste this into your UserForm Code module:

Code:
Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdOK_Click()
If txtPass <> &quot;pass&quot; Then
    MsgBox &quot;You have entered the wrong password! Please try again!&quot;, vbExclamation, &quot;Wrong Password&quot;
Else
    MsgBox &quot;Congratulations!!&quot;, vbInformation, &quot;Correct Password&quot;
    Unload Me
End If
End Sub

Private Sub UserForm_Initialize()
With txtPass
    .Value = &quot;&quot;
    .SetFocus
End With
End Sub

My TextBox's name was txtPass, my Cancel Button was cmdCancel and my OK Button was cmdOK.

I hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top