简体   繁体   English

如何以vb.net形式创建受密码保护的按钮

[英]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. 我有一个VB.NET表单,其中包含供用户输入其详细信息的文本框。 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. 基本上,我想使delete按钮的密码受保护,以便普通用户无法删除其任何详细信息。 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 谢谢

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? 如果您确实希望输入密码才能使用按钮,为什么不将其保持启用状态,并在click事件处理程序中显示密码捕获表格? You only execute the rest of the code if the password is correct, else the event gets cancelled. 仅当密码正确时才执行其余代码,否则事件将被取消。

My friend try this... CODE *Note:You should start the form with the delete button not enabled 我的朋友尝试此操作... CODE *Note:You should start the form with the delete button not enabled

Let textbox1 contain password and button1 is the Delete button 让textbox1包含密码,让button1为Delete按钮

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

If a=password Then
    button1.Enable=True
Else
    button2.enable=false
End if
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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建VB.NET密码保护的安装程序 - Create VB.NET password protected installer 如何使用vb.net表单删除MS Access数据库的记录以及如何使用vb.net表单输入受密码保护的数据库 - How to delete records of MS access database using vb.net form and how to enter a password protected database using vb.net form 如何使用VB6 / VB.NET打开受密码保护的PDF? - How to open a password protected PDF using VB6/VB.NET? 通过vb.net打开受密码保护的Microsoft访问文件 - Open password protected Microsoft access file through vb.net 检查共享文件夹是否在vb.net中受密码保护 - Check if a shared folder is password protected in vb.net 如何使用受密码保护的访问数据库作为Vb.net项目的后端…? - how can i use a PASSWORD protected ACCESS database as a backend of my Vb.net project…? 如何使用VB.NET打开受密码保护的共享网络文件夹? - How to open a password protected shared network folder using VB.NET? 忘记密码表格问题VB.net - Forgot Password Form Issues VB.net 为什么私有vs保护如何使用VB.NET在ASP.NET中创建按钮单击事件? - Why Private vs Protected for how a Button Click Event is Created in ASP.NET using VB.NET? 如何创建一个按钮来在VB.NET中打开以前的Excel工作表? - How to create a Button that opens the previous excel sheet in VB.NET?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM