VB AddHandler Problem

when using more than one Form , you must declare an instance of any other Form , so to call a function in Form2 using Form1, you would need to declare Form2 first. eg:
Code:
/// somewhere in Form1 ( like say a sub / click event )
Dim frm2 As New Form2()
frm2.Show() /// if you want to see Form2 ( otherwise leave this out )
frm2.Testclick() /// use Form2s Testclick sub.
 
thanks, that certainly worked. I am still puzzled by my inability to use RaisEvent and an event handler since as far as I can tell my code seemed to be correct - most of the books I have mirror what I had done.

However, for now I will use what you suggest - its certainly far better than my workaround which had been to set a variable in shared common and pick it up with a Timer!!

again, thanks.
 
Just an aside to this. Creating a reference to Form1 in Form2 allowed the TestClick to be called from Form2, however creating a new instance meant that any reference to Form1s controls in TestClick operated on the new (invisible) instance rather than my already existing Form1. So the controls were not updated.

Since Form1 actiually creates Form2, I am now passing Me to Form2s New method and saving it as a reference in an Object variable. Now, TestClick in Form2 updates Form1 correctly.
 
Back
Top