i'm using hide and close events from form. but what i found out is it creates every time another instance
this is the code i used
Dim AFormInstance As New form1()
AFormInstance.Show()
Me.Hide()
How to get 1 instance instead of many?
i'm using hide and close events from form. but what i found out is it creates every time another instance
this is the code i used
Dim AFormInstance As New form1()
AFormInstance.Show()
Me.Hide()
How to get 1 instance instead of many?
Declare a class-level variable instead of a procedure-level one.
Something like this should work just fine.Code:Public Class MyForm
Inherits System.Windows.Forms.Form
Public FRM as new Form()
Public Sub ShowFRM()
FRM.Show()
End Sub
End Class
I disagree. Passing references like that would only lead to spaghetti code. It can be done, but your code would be a bit harder to read, and harder to debug if you have a lot of forms.Quote:
Originally posted by Edneeis:
I think you have to track the forms at a module level or pass references of the instances back and forth to the different forms.
I think you have to track the forms at a module level or pass references of the instances back and forth to the different forms.
If you want to pass data back and forth, you will need a reference to do so or another class that acts as an intermediatery (spell) between the two. Edneeis is right.
Hmm. With an application that has a lot of forms, it might get difficult to keep track of all those form references.Quote:
Originally posted by hellswraith
If you want to pass data back and forth, you will need a reference to do so or another class that acts as an intermediatery (spell) between the two. Edneeis is right.
I like the idea of a shared class acting like an intermediatery though. It would help to keep things centralized and simple.