Hello everyone, I have a program that i am working on using more than one Form. The way i am going through forms is by minimizing my first form then showing the other forms. I was wondering if i start the program from a module maybe i can unload forms making my program much more effective. Here is some of my current code:

            Me.WindowState = FormWindowState.Minimized      

I would love to unload the current form and show emainForm. Right now i have an empty module, i would imagine i would have to make a private sub, but i wouldn't know the syntax from there. I'm guessing welcomeForm.load then unload....?

9 Years
Discussion Span
Last Post by jhonnyboy

This doesn't exactly answer how to do it from the module, but shows how to create and dispose forms (from the "main" form)

' A global variable to "hold" the form
Private aForm As Form

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  ' Create a new instance from the Form2 class
  aForm = New Form2
  ' Show the form instance

End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  ' Close the form
  ' And dispose it
  aForm = Nothing

End Sub

I didn't check it, but you should be able to create and dispose forms from a module with the above code.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.