I have a line of code that isn’t working to identify that a window is NOT a window.
If App.WindowCount >= 1 And Not App.Window(0) ISA SrchDWin And Not App.Window(0) ISA LilDWindow And Not App.Window(0) ISA MainPage Then
App.Window(0).Show
ElseIf ...
Would someone please explain why this If statement isn’t being selected.
Outside of the Not window part it is being selected. I know this because I broke the Not section into an inner IF statement and it was selected. That code is below
If App.WindowCount >= 1 Then
If Not App.Window(0) ISA SrchDWin And Not App.Window(0) ISA LilDWindow And Not App.Window(0) ISA MainPage Then
App.Window(0).Show
End If
ElseIf ...
the first code seems alright unless I miss something. Personally I like to use () and break a long statement on many lines, for example:
If App.WindowCount >= 1 _
And (Not App.Window(0) ISA SrchDWin) _
And (Not App.Window(0) ISA LilDWindow) _
And (Not App.Window(0) ISA MainPage) Then
App.Window(0).Show
ElseIf ...
To me this form is easier to read. The nested And clauses stop being evaluated as soon as one of hem is false. That ‘may’ explain why the If in the first snippet would never be executed. I suggest you to use () and _ to break the statement on many lines, just to see if with () that would work
I put the line down as suggested and it didn’t improve it any
If App.WindowCount >= 1 _
And ( Not App.Window(0) ISA SrchDWin )_
And ( Not App.Window(0) ISA LilDWindow )_
And ( Not App.Window(0) ISA MainPage ) Then
Put the result of the several conditions in boolean variables and see which condition fails:
Var windowCountCondition As Boolean = App.WindowCount >= 1
Var srchDWinCondition As Boolean = Not App.Window(0) ISA SrchDWin
Var lilDWindowCondition As Boolean = Not App.Window(0) ISA LilDWindow
Var mainPageCondition As Boolean = Not App.Window(0) ISA MainPage
If windowCountCondition _
And srchDWinCondition _
And lilDWindowCondition _
And mainPageCondition Then
App.Window(0) is a function call.
You could just put the result into a variant and then check the variant content.
See it in the debugger when you stop at a break point.
And also use Introspection.GetType() to query type and thus the class name to show verify for logging.
I tried both types of brackets {} and got a “syntax error” with no explanation on both.
I also tried looking up bracket in the LR and there were no obvious subject headings for them or parentheses. Grumble.
Also, I know what App.Window(0) is. (Thanks Christian) I know it is also not one of the window types.
If App.WindowCount >= 1 _
And { Not App.Window(0) ISA SrchDWin }_
And { Not App.Window(0) ISA LilDWindow }_
And { Not App.Window(0) ISA MainPage } Then
App.Window(0).Show
ElseIf App.WindowCount = 0 Then
MainPage.Show
Else
MainPage.Show
End If
This problem has become an “ego” issue. I could very easily switch to a positive statement using "OR"s but I’d really like to find out about the NOT’s
If (App.WindowCount >= 1) And Not ( App.Window(0) ISA SrchDWin) And Not (App.Window(0) ISA LilDWindow) And not ( App.Window(0) ISA MainPage) Then
App.Window(0).Show
ElseIf ...
If App.WindowCount >= 1 _
And Not ( App.Window(0) ISA SrchDWin )_
And Not ( App.Window(0) ISA LilDWindow )_
And Not ( App.Window(0) ISA MainPage ) Then
App.Window(0).Show
i not understand why are you using Window(0)
i guess the first window is the start default window from app settings in inspector.
i use this to close all others before the main close
Dim n, i As Integer
n = App.WindowCount
System.DebugLog(App.WindowCount.ToText)
For i = n-1 DownTo 0
If App.Window(i) IsA WindowUsers Then App.Window(i).Close
If App.Window(i) IsA WindowFind Then App.Window(i).Close
If App.Window(i) IsA WindowSettings Then App.Window(i).Close
If App.Window(i) IsA WindowAbout Then App.Window(i).Close
If App.Window(i) IsA WindowFeedback Then App.Window(i).Close
If App.Window(i) IsA WindowChart Then App.Window(i).Close
Next
You haven’t put the first condition in parentheses. Try
If ( App.WindowCount >= 1 ) _
And Not ( App.Window(0) ISA SrchDWin )_
And Not ( App.Window(0) ISA LilDWindow )_
And Not ( App.Window(0) ISA MainPage ) Then
App.Window(0).Show
Grumble.
It was not window(0) that was what I was looking for. It was window(1). It has been so long since I wrote this code that I thought I had the window()s correct.
Thank you all