[quote=310414:@Michel Bujardet]Oh but it would. At present and even if it were invisible there is a window hanging around whatever the result of test. If find that sloppy. IMHO it would be better to create the instance in the testing code :
Public Sub test(Win as String)
if 1 = 2 then
Select case Win
Case "frmName"
dim frm as new Window2
frme.ShowModal
case "otherWindow"
dim frm as new Window2
frm.ShowModal
else
msgbox( "here" )
end if
End Sub
So if the test is negative, there is no window created.
Alternatively, the window should be closed if the result is negative and the window is not needed.[/quote]
it would have NO effect on Nathans issue - absolutely none
Try your revised code with
Public Sub test(Win as String)
if 1 = 2 then
Select case Win
Case "frmName"
dim frm as new Window2
// frme.ShowModal
case "otherWindow"
dim frm as new Window2
// frm.ShowModal
else
msgbox( "here" )
end if
End Sub
commented out and NO change to the visible property of either frme or frm2
They’ll show regardless of the ShowModal call
Alternately create a simple project with Window1 and Window2
Turn Window2.implicit instance OFF (dont touch VISIBLE)
On Window 1 put a button with one line in the action event
dim w as new Window2
Run and press the button
The problem is NOT Nathans code in any way
In fact I would not do what you’re suggesting as this is a great example of whats know as “control coupling” which is NOT a good thing to strive for