Hi
I have a form in Visual Basic 6. I want on form load/activate it should ask for password
Thanks
Hi
I have a form in Visual Basic 6. I want on form load/activate it should ask for password
Thanks
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sangeetha SPosted Apr 22, 2025, 6:45 AM
Private Sub Form_Load()
Call AskForPassword
End Sub
Private Sub Form_Activate()
Call AskForPassword
End Sub
Private Sub AskForPassword()
Dim password As String
password = InputBox("Please enter the password:", "Password Required")
If password <> "your_password_here" Then
MsgBox "Incorrect password. The application will now close.", vbCritical
Unload Me
End If
End Sub
Daniel WrightPosted Apr 22, 2025, 3:20 AM
It sounds like you're looking to add a password prompt functionality to your Visual Basic 6 form, triggering it upon form load/activate. This feature adds a layer of security to your application, ensuring only authorized users can access it.
You can achieve this by adding a simple input box that prompts the user to enter a password when the form loads or activates. Here's a basic example of how you can implement this in Visual Basic 6:
In this code snippet, the `Form_Load` event triggers the input box to appear when the form loads. The user needs to enter the correct password ("YourPasswordHere" in this example) to continue. If the password matches, you can allow access to the form; otherwise, you can reject access and optionally close the form.
Remember to replace "YourPasswordHere" with your actual password. Additionally, consider enhancing security measures by encrypting the password or using more advanced authentication methods based on your application's requirements.
I hope this example helps you implement the password prompt feature in Visual Basic 6 successfully. If you have any more questions or need further assistance, feel free to ask!