How to insert a working macro in USERFORM, to hide the password with ***** asterisks

K0st4din

Active Member
Joined
Feb 8, 2012
Messages
488
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello, everyone,
thanks to Logit from the forum we were able to reach the final of my request for help.
This is the link to my inquiry:
Setting a Trial Period in Excel

However, at one point I realized that we had not done it right. The password I can write (when the time comes, you can see it).
I searched a lot, but almost everyone says that in order not to be seen, it must be made in USERFORM1.
I ask for your help, how to unite the macro working perfectly, but to go through USERFORM to hide the password ******* with asterisks.
Thank you in advance for your help.


This macro works just perfect for my needs
VBA Code:
Sub pass()
Dim mbox As String
Dim MyDate As Variant
Dim Passwd As String

MyDate = #8/30/2020#  ' Assign a date. tuk se zapisva krainata data, dokoga da byde otvoren.
Passwd = "123456" 'Assign password

Application.ScreenUpdating = False
Sheets("Sheet1").Visible = True
'Sheets("Sheet2").Visible = xlVeryHidden
Application.ScreenUpdating = True

If Date > MyDate Then
MsgBox "Oops! Test/Evaluation period of the utility has been expired." & vbCrLf & _
  "Pls ask the concern person to get the updated utility.", vbCritical, "Outdated/Expired Version"
  mbox = Application.InputBox("Pls input the password/code to continue...", "Password")

  If mbox <> Passwd Then
  MsgBox "Incorrect Password" & vbCrLf & _
  "Pls ask the concern person to get the correct password.", vbCritical, "Wrong password"

Application.Quit
With ThisWorkbook
  .Save
  .ChangeFileAccess Mode:=xlReadOnly
  'Kill .FullName
  .Close SaveChanges:=False
  End With
Else
  'Sheets("Sheet2").Visible = True
  Sheets("Sheet1").Visible = False
  End If

End If

End Sub



Code for USERFORM1
VBA Code:
Private Sub CheckBox1_Click()
If UserForm1.CheckBox1.Value = True Then
UserForm1.TextBox1.PasswordChar = ""
Else
UserForm1.TextBox1.PasswordChar = "*"
End If
End Sub

Private Sub CommandButton1_Click()
If UserForm1.CheckBox1.Value = "123" Then
Unload Me
MsgBox ("Welcome!")
Else
Unload Me
MsgBox ("Invalid password, try again!")
UserForm1.Show
End If
End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub
2020-06-13_160757.jpg

2020-06-13_160845.jpg
 
most welcome & glad resolved - many thanks for feedback

Dave
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,214,653
Messages
6,120,755
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top