To download NI software, including the products shown below, visit ni.com/downloads.
Overview
The example demonstrates Password Lock in Tab Control.
Description
The example Tab Control has Home and Config tabs. The Home tab is freely available to all users, but the Config tab is password-protected with a simple password ("engineer"). Any time the Config tab is selected, the user will be prompted for the password, and will be unable to see certain controls if the password is not entered or is invalid.
The accompanying code is straightforward. After setting an initial tab to be visible and hiding the sensitive controls, the VI enters a continuous While Loop to wait for user input. Input is handled by an Event Structure, which contains event handlers for a Value Change event on the Tab Control and a Value Change event on the Stop button. When the user clicks a new tab on the Tab Control, the Tab Control Value Change event executes, and uses a Case structure to handle the tab chosen by the user. In this example, changing to the Home tab (an unprotected tab) simply hides the sensitive data.
Changing to the Config tab will call the Request Password Express VI and execute one of two cases based on whether the password was correct or not. If the password is correct, the True case will execute, and the sensitive data will be made visible. If the password is incorrect, the sensitive data remains hidden.
Finally, an event handler for a Value Change on the Stop button allows the loop to exit when the user chooses to stop the VI.
Adding more unprotected or protected tabs would be as simple as adding new tabs to the Tab Control and then creating cases for them in the Case Structure in the Tab Control Value Change event handler.
Requirements
Steps to Implement or Execute Code
Additional Information or References
VI Front Panel
VI Block Diagram
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.
First of all, you initially have the sensitive data visible. Your constant outside of the while loop is wrong (should be a FALSE).
There's no need for the wait due to the event structure.
It is best to put your controls in the their respective event cases. This will also allow the stop button to reset since it is set to latch.
Otherwise, it is a good concept - one I've implemented many times. Good job.
Hey crossrulz, thanks for the feedback! I've updated the example to reflect the changes you suggested.
Not quite. The stop terminal should be in the Stop Value Changed event. I would also put the tab terminal in the Tab Control Value Change event (mostly for consistancy).
Done!
Hi,
How can i change the name of tab " config" to Authority?
Password control was working in XP but stopped working in Windows 7. It has to be in the permission in Windows. Where is the password information stored so I can make sure the permissions are set to read write?