Password Userform help !!!!

K

K1KKKA

Sub Sunselect()
Dim PassStr As String
PassStr = InputBox("Enter Password Please", "My Password
Prompt")


If PassStr = "Manager" Then
Sheets("Sun").Select
Range("A11").Select
Else
MsgBox "Wrong Password Entered"
End If

End Sub



Am currently using this to ask for a password before allowing people to
view the sheet, but would prefer to use a usrform, i know how to creat
and asign the form, but am not sure of the exact text as fairly new to
userforms,


Prefer to have password char as ******** when typed and have been told
this is not possible with input box.


Any help
 
J

John Cleese via OfficeKB.com

I've had managed to use the following code within a userform textbox change
function, that will read characters as they are typed into the textbox and
add them to a temporary password variable 'tmpPWord', then replace the typed
character with a * for display in the textbox.

Therefore, the user will only see a row of *'s in the textbox, yet the actual
password is stored in temporary variable 'tmpPWord'. Try it out! I hope it
works for you.

Private Sub TextBoxPassword_Change()

Dim repeatCancel As Boolean
Dim i As Integer
Dim tmpTextBoxText As String

tempWord = ""

If Len(TextBoxPassword.Value) < Len(dispPassWord) Then
dispPassWord = Left(dispPassWord, Len(dispPassWord) - 1)
tmpPWord = Left(pWord, Len(tmpPWord) - 1)
Else
If Right(TextBoxPassword.Value, 1) <> "*" Then
If Len(TextBoxPassword.Value) > 1 Then
tempWord = Right(TextBoxPassword.Value, 1)
dispPassWord = dispPassWord & "*"
Else
tempWord = TextBoxPassword.Value
dispPassWord = "*"
End If
tmpPWord = tmpPWord & tempWord
TextBoxPassword.Value = dispPassWord
End If
End If

End Sub

Regards

John Cleese
 
D

Dave Peterson

Check your other post.
Sub Sunselect()
Dim PassStr As String
PassStr = InputBox("Enter Password Please", "My Password
Prompt")

If PassStr = "Manager" Then
Sheets("Sun").Select
Range("A11").Select
Else
MsgBox "Wrong Password Entered"
End If

End Sub

Am currently using this to ask for a password before allowing people to
view the sheet, but would prefer to use a usrform, i know how to creat
and asign the form, but am not sure of the exact text as fairly new to
userforms,

Prefer to have password char as ******** when typed and have been told
this is not possible with input box.

Any help
 
K

K1KKKA

I've had managed to use the following code within a userform textbox change
function, that will read characters as they are typed into the textbox and
add them to a temporary password variable 'tmpPWord', then replace the typed
character with a * for display in the textbox.

Therefore, the user will only see a row of *'s in the textbox, yet the actual
password is stored in temporary variable 'tmpPWord'. Try it out! I hope it
works for you.

Private Sub TextBoxPassword_Change()

Dim repeatCancel As Boolean
Dim i As Integer
Dim tmpTextBoxText As String

tempWord = ""

If Len(TextBoxPassword.Value) < Len(dispPassWord) Then
dispPassWord = Left(dispPassWord, Len(dispPassWord) - 1)
tmpPWord = Left(pWord, Len(tmpPWord) - 1)
Else
If Right(TextBoxPassword.Value, 1) <> "*" Then
If Len(TextBoxPassword.Value) > 1 Then
tempWord = Right(TextBoxPassword.Value, 1)
dispPassWord = dispPassWord & "*"
Else
tempWord = TextBoxPassword.Value
dispPassWord = "*"
End If
tmpPWord = tmpPWord & tempWord
TextBoxPassword.Value = dispPassWord
End If
End If

End Sub

Regards

John Cleese










Message posted viahttp://www.officekb.com- Hide quoted text -- Show quoted text -


Many thanks works for me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

password userform 2
password as ******** 2
Password as ******* 1
Password on a field 3
Password 3
Tab password to view 1
How to hide password? 1
Macro password-All sheets visible 4

Top