Help with closing all windows

Dim x As Integer = MsgBox("Are you sure you want to logout?",4+48) if x=6 then For i As Integer = 0 To WindowCount -1 MsgBox(str(WindowCount)) Dim w As Window = Window(i) w.Close Next frmLogin.Show end

This does not work! WindowCount works and does show the number but it only ever closes one window, any reasons why?

Also, why am I not able to do the following:?


for i As integer = WindowCount - 1 downto 0

[quote=154367:@Rami Hassan]Also, why am I not able to do the following:?

The “Name” property of the IDE is not the name of an instance of the window, it is the name of the Class of window you are creating. You can use that window class to create multiple instances. As such, it is not directly available to an instance. The closest you can get is through introspection.

Perfect, thank you very much, Peter!

I see, thanks. What is introspection and how is it used?

If you wanted to close all windows that were not Window1 you could do the following:

[code]for i as integer = window count-1 downto 0
if window(i) isa Window1 then CONTINUE //Don’t close any instances of this window


Note that window1 is the name of the window class and NOT the instance of window1. Confusing, I know, but it’s an important distinction.