Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a better way to manage my If statements?
#1
Not Solved
Is there a better way to manage my If statements?

My issue is; I have 10 or so dialog boxes and depending on which I have found, I need to use the code associated with the dialog box. I have 2-5 objects that I look for to determine which dialog box that I have.

My problem; is, if the third If statement is not found, my code Exits all of my If statements.
My goal; is to have code to search each of the set of Dialog boxes until it finds the correct “complete” match.

My code:
Code:
'1 – Dialog Box
If .WebElement("WebTable_AccountNo").Exist(0) Then
    If  .WebEdit("StartDate").Exist(0) Then
        If .WebElement("mm/dd/yyyy_Start").Exist(0) Then    
             If .WebCheckBox("CheckboxSave").Exist(0) Then
                Call UseReport1
            End If
        End If
    End If
'2 – Dialog Box
ElseIf .WebElement("WebTable_AccountNo").Exist(0) Then
    If .WebRadioGroup("TradeDtRange").Exist(0) Then
        Call UseReport2
    End If
'3 -- Dialog Box
ElseIf .WebElement("WebTable_AcctType").Exist(0) Then
    If .WebElement("WebTable_CAP").Exist(0) Then
        If .WebElement("StartDate").Exist(0) Then
            Call UseReport3
        End If
    End If
'4 – Dialog Box
ElseIf .WebElement("WebTable_CAP").Exist(0) Then
    If .WebEdit("SubFirm").Exist Then
         If .WebElement("StartDate").Exist(0) Then
            Call UseReport4
        End If
    End If
'5 – Dialog Box
ElseIf .WebElement("WebTable_AccountNo").Exist(0) Then
    If .WebElement("StartDate").Exist(0) Then
        If .WebCheckBox("CheckboxSave").Exist(0) Then
            If .WebList("Select_Month").Exist Then
                       Call UseReport5
            End If
        End If
    End If
'6 – No Dialog Box
ElseIf ReportName = "ALL IMAGED CLIENT DOCUMENTS" Then
    Call UseReport6
Else
    MsgBox ("No matching Search Preference dialog box found")
End If


How can I change my code so that if I reach 1-Dialog Box’s third If statement and Fails, the code will check the next 2 –Dialog Box’s code. Or must I complete each Dialog box’s If..If..If… EndIf…EndIf..EndIf statements, etc?


Attached Files
.pdf   Is there a better way to manage my If statements.pdf (Size: 34.29 KB / Downloads: 77)
Reply


Messages In This Thread
Is there a better way to manage my If statements? - by mv8167 - 09-03-2011, 01:14 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  In qtp how to manage status bar for portal(SAP WEB Application) kamal262007 0 2,677 03-08-2013, 12:58 PM
Last Post: kamal262007
  problem in looping statements... navyasatish 5 4,239 02-02-2012, 02:23 PM
Last Post: rajpes
  Create script to manage different browser. CapitanFuturo 1 2,445 10-19-2011, 04:54 PM
Last Post: rajpes
  Anyone know the difference of the 2 statements martinlam 3 4,037 08-31-2010, 02:44 PM
Last Post: QTPLearn
  Conditional Statements from Data Table golfer999999 1 3,283 03-05-2009, 08:43 PM
Last Post: sepgs2004

Forum Jump:


Users browsing this thread: 1 Guest(s)