close a vb.net multi-form ppc app efficiently

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys

i've read a tonn of web pages on this and none of them agree.
I'm tring to find an effective and working method of closing
everything i have opened in my vb.net application running on
a pocket pc 2003.

I've got it opening via sub main coz there's some code i only want
run once then it goes on to open the frm_main as a dialog which
in turn opens several other forms using this type of method:

Private Sub Button2_Click(...ect..) Handles Button2.Click
Dim frm_depl As New frm_depl
frm_depl.Show()
Me.Hide()
End Sub

When i come to closing the main form i use this:

Dim frm_scene As New frm_scene
Dim frm_depl As New frm_depl
frm_scene.Dispose()
frm_depl.Dispose()
Me.Dispose()

am i doing something wrong coz using this as a close i get forms opening
randomly, sometimes the program is still resident in memory and even when i
open it again it still has the variables assigned in memory!

Bit crazy, any help would be relaly really really great!
Thanks so much
 
From your button2_click you show a form but you don't keep a reference to
it. You should store the reference i.e.
Private frm_depl As frm_depl
Private Sub Button2_Click(...ect..) Handles Button2.Click
frm_depl = New frm_depl
frm_depl.Show()
Me.Hide()
End Sub

When you close the form you should not create new instances of your forms
e.g.
frm_depl.Close() 'This is the same reference you opened from the button
click
Me.Close()

Cheers
Daniel
 
Thanks brilliant stuff

Daniel Moth said:
From your button2_click you show a form but you don't keep a reference to
it. You should store the reference i.e.
Private frm_depl As frm_depl
Private Sub Button2_Click(...ect..) Handles Button2.Click
frm_depl = New frm_depl
frm_depl.Show()
Me.Hide()
End Sub

When you close the form you should not create new instances of your forms
e.g.
frm_depl.Close() 'This is the same reference you opened from the button
click
Me.Close()

Cheers
Daniel
 
Back
Top