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:

emainForm.Show()
            Me.WindowState = FormWindowState.Minimized      
            Me.Hide()

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....?

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
  aForm.Show()

End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  '
  ' Close the form
  aForm.Close()
  ' 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 is just what i was looking for. Thanks!

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.