Hello all,
I am firing an event on one form that is getting handled on another.
Following is my basic code:
__________________________________________
ON FORM #1:
Public WithEvents A_Form2 As New FORM2
Try
A_Form2.Show()
Catch ex As Exception
Dim A_Form2 As New FORM2
A_Form2.Show()
End Try
Private Sub MaketheChanges() Handles A_Form2 .MakeChanges
End Sub
________________________________________________
ON FORM2
Public Event MakeChanges()
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
RaiseEvent MakeChanges()
End Sub
_______________________________________________
This code is working perfectly when I first start the program. But if
I close A_Form2 and then reopen it, the event won't fire. I can
understand why. When I create a new instance of FORM2, I am simply
writing "Dim", rather than "Public WithEvents". The problem is that I
can't figure out away to declare a new instance of a form withevents
at runtime. Everything I try gets an error. Does anyone know how to
do this or even if it is possible?
Please let me know.
Christian Fröschlin - 19 Feb 2007 08:13 GMT
> Catch ex As Exception
> Dim A_Form2 As New FORM2
No need to declare a new variable just to create a new object instance.
Replacing this with "A_Form2 = New FORM2" should work.
bidalah@yahoo.com - 22 Feb 2007 16:30 GMT
> > Catch ex As Exception
> > Dim A_Form2 As New FORM2
>
> No need to declare a new variable just to create a new object instance.
> Replacing this with "A_Form2 = New FORM2" should work.
Ofcourse. Thank you.