Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passwords for buttons

Posted on 2003-02-23
6
Medium Priority
?
194 Views
Last Modified: 2010-05-01
How do I add a password to a command button??

Say...I have a button(cmdErase), I will want a pop-up that comes up for users to key in password before they can access to clicking cmdErase and run the functions in it.How do i do that??
0
Comment
Question by:VivienW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 90 total points
ID: 8006643
Here is an example:

in a module:

public isPass As boolean
public const pwd As string = "123456"

in main form:

Private Sub cmdErase_Click()
    ispass = False
    Form1.Show vbModal
    If ispass Then
        'Do thing here
    End If
End Sub

in Form1:

Private Sub Command5_Click()
    If Text1.Text = pwd Then
        ispass = True
        Unload Me
    Else
        MsgBox "Wrong password"
    End If
End Sub

cheers
0
 

Author Comment

by:VivienW
ID: 8006833
Hi ryancys,

   This line of code is giving me an error:

public const pwd As string = "123456"

   Pls advise.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8006925
Tested, it should be working, at least on VB 6..

if still working, try define 'pwd' like this:

public pwd As string

and it the main form's Form_load event, put this line:

pwd = "123456"

of course, get the password from the source.

cheers
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:VivienW
ID: 8006961
When password is entered,I am able to view the entered password which is "123456", how do I make it unseen like "******" ?? and still check for the correct password entered?
0
 

Author Comment

by:VivienW
ID: 8007254
Hi ryancys

   You're right.public const pwd As string = "123456" does work.

   To display password entered in textbox as "*", i used this:

Private Sub Form_Click()
   If txtPassword.PasswordChar = "" Then
      txtPassword.PasswordChar = "*"
   Else
      txtPassword.PasswordChar = ""
   End If

End Sub

  but it does now work.
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 8007309
sorry that didnt reply as soon as possible, busy working, you know.. anyway, glad you solved the problem. cheers
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question