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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sangeetha SRank #212 · 11.4K reputationPosted Apr 22, 2025, 2:45 AM EDT
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 WrightRank #2,947 · 489 reputationPosted Apr 21, 2025, 11:20 PM EDT
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:
Private Sub Form_Load() Dim password As String password = InputBox("Enter the password:") If password = "YourPasswordHere" Then ' Password correct, proceed with form display or any further actions Else ' Incorrect password, you can display an error message or take appropriate action MsgBox "Incorrect password. Access denied.", vbExclamation Unload Me ' Close the form if the password is incorrect End If End SubIn 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!