hi i am new to visual basic and i am using vb6, i have senior year project for invenotry managment system..my problem is that if one form is open then the user must not b able to peform other functions(open another form, close application etc) unless the current form is get closed please help me in this

Dani AI

Generated

Short summary and practical follow-ups (adds to the replies from and ): the cleanest UI pattern to force the user to finish one task before doing others is to present a dialog that prevents interaction with the rest of the app, and a corrupt or wrong IDE can make the modal option look like it "does not exist" — which is what happened for and was fixed by reinstalling VB6. Below are safe alternatives and a couple of small, copy-pasteable snippets you can apply immediately.

To prevent closing the whole app while a critical task is active, handle the form unload query and cancel it when needed:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If Not allowClose Then
        MsgBox "Please finish the current task first."
        Cancel = True
    End If
End Sub

Set the module-level Boolean allowClose to True only when it is safe to exit.

If you need to keep background work running but stop the user from touching the main UI, disable main-form controls before showing the child and re-enable them afterward:

Private Sub ToggleMainUI(enabled As Boolean)
    Dim c As Control
    For Each c In frmMain.Controls
        c.Enabled = enabled
    Next
End Sub

Call ToggleMainUI False before opening the blocking dialog and ToggleMainUI True after it closes.

Troubleshooting checklist if the modal option is not recognized: confirm you are running classic VB6 (not VB.NET), test with a tiny new project to isolate the IDE, avoid declaring variables with names that shadow VB constants, and repair/reinstall VB6 if core constants or libraries are missing. For long-running operations avoid freezing the UI — do the work in a background thread/process or provide a modeless progress form so the app stays responsive.

Recommended Answers

All 5 Replies

show your form like this example..

Form1.Show vbModal

if you put vbModal when showing a form, this will prevent the user for clicking other form unless the form1 is close...

thanks for your help; but when i used vbModal debug gives error that object not found vbModal any suggestions??

Are you sure you are using Visual Basic 6.0 and not VB.NET or VBA (access, word, excel,etc)?

well i think if you are using VB.NET / 2008 you can do this code.. i think... LoL

FormName.ShowDialog()

hi;
my problem is solved by using vbModal actually the problem is in the installation of VB6 i have re-install it now the problem is solved, because in first attempt vb6 was installed with some errors. thanks for all of your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.