opening and closing forms

shamif
12-07-2004, 12:19 PM
I have two forms say Form1 and Form2. The program starts at Form1 and then I Hide Form1 and Open Form2. Then I do some stuff in Form2 and hide Form2 and open Form1. I want my program to go back and forth with the two forms. Form2 has an ActiveX control. Every time I close Form2 I want to dispose the ActiveX control. And Every time Form2 is opened I want to recreate it. Every time I close Form2 the ActiveX control throws all kinds of errors, so that’s I want to dispose the ActiveX control. Right now I have to close the program and start the program. Here is my code so far,

‘when opening Form2 from Form1
Dim oForm as Form
Me.Hide()
oForm = new Form2
Form2.ShowDialog()

‘When closing Form2 from Form2
Dim oForm as Form
Me.Hide
oForm = new Form1
Form1.ShowDialog()

Obviously this is not the best method since I have to close and open the program all the time. What is the best way to do it? How can I dispose the ActiveX control (It does not have .dispose() )? Should I use close instead of hide? Or should I use something else? What is my best option?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum