Parth Doshi
Parth Doshi

Reputation: 4208

How to create a password protected button in a vb.net form

I have a VB.NET form that contains textboxes for the user to enter his details. I have a delete button in the same form that I want only the administrator or any authorized person to be able to use.

Basically, I want to make the delete button password protected so that the normal user can't delete any of his details. only the admin who has the admin password can delete it.

Is it possible to create a password protected button? I searched on the Internet but couldn't find any links that would help me.

Thanks

Upvotes: 0

Views: 5686

Answers (3)

OONYU ALI
OONYU ALI

Reputation: 1

dim as user as string
dim as pass as integer

user ="Admin"
pass ="1234"
if (user = username.text And pass =password.text) then
msgbox"GOOD"
ELSE
msgbox"SORRY"
end if

Upvotes: 0

Almero Rick
Almero Rick

Reputation: 118

My friend try this... CODE *Note:You should start the form with the delete button not enabled

Let textbox1 contain password and button1 is the Delete button

Dim a=textbox1.text
Dim password="admin123"

If a=password Then
    button1.Enable=True
Else
    button2.enable=false
End if

Upvotes: 0

Widor
Widor

Reputation: 13275

From a usability perspective I'd suggest a 'better' way to implement it would be to use some sort of role-based model, whereby the user authenticates when they begin using the app and role-specific form elements are then displayed accordingly.

If you really want a password to be entered to use a button, why not leave it enabled and in the click event handler, show a password-capture form? You only execute the rest of the code if the password is correct, else the event gets cancelled.

Upvotes: 2

Related Questions