Micro Focus QTP (UFT) Forums
Select case is not being executed in a Function - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Select case is not being executed in a Function (/Thread-Select-case-is-not-being-executed-in-a-Function)



Select case is not being executed in a Function - Anupama - 05-25-2018

Hi I have this below code where everything else in the function works fine except for the Select case. The select case is not even being executed. It executes till the if statement and then exists the function. does not throw any error or anything. Can someone tell What am I doing wrong.

Code:
Function Submit_Wirelog(SelectSubmitOrCancel)
    Dim funcName : funcName = "Submit"        
    Dim setupFuncName : setupFuncName =   "SETUP|" & funcName

    
    If Browser("Browser").Page("Pge").WebElement("Ele").ExistsAbort (10) Then
        Select Case ucase(SelectSubmitOrCancel)
            Case "Submit"
                Browser("Browser").Page("Pge").WebButton("Btn").ClickAbort (20)
                Created =Browser("Browser").Page("Pge").WebElement("LblLogNumber").GetROProperty("innertext")
            Case "Cancel"
                Select Case ucase(parameter.Item("SubmitYesorNo"))
                        Case "YES"
                            msgbox "Cacelled"
                        Case "NO"
                            msgbox "NO"
                End Select
        End Select
    else
        ResultOutput "Pass", "Expected:Verified and created wireLog"&vbnewline,"Actual:Done Successfully"        
    End If    
    
End Function



RE: Select case is not being executed in a Function - Anupama - 05-25-2018

Solved it. Since I used the ucase for switch statement the Case values should be in upper case like below. Not deleting this post as it be useful for someone else.
Code:
Select Case ucase(SelectSubmitOrCancel)
            Case "SUBMIT"
                
                    Case "CANCEL"