I trust that your frames are just basic examples, as they are otherwise practically identical?
Anyhoo, how about :
What were you intending your frame2 field in MyFrame2 to represent? itself, or a third frame?
Anyhoo, how about :
Method Button2Clicked(event:wxCommandEvent) Close() End Method
What were you intending your frame2 field in MyFrame2 to represent? itself, or a third frame?