Page 1 of 1

User code with If and ElseIf

Posted: Thu Mar 29, 2012 3:09 pm
by byonush
I have the first If and ElseIf working properly. If the cell it looks at has a positive number it will click the BUY button. If it has a negative it will click the CVS button. The problem I am having is when the cell is not there at all. What I would like to do is the above and if the first two conditions are not there meaning no cell at all then click the BUY button and continue. Right now if it comes to a symbol that does not populate a cell the playback stops. Here is the code I am using. I have tried everything I can think of for the final ElseIf but nothing is working for that.

Public Sub Invoke_Action_Side()
    	      	
        	If repo.PlaceTradeScreen.OrderShareTotal.RowRow_1.CellFirm_Total_row_0.Text >= 0 Then
        	   Report.Log(ReportLevel.Info, "Invoke Action", "Invoking Press() on item 'PlaceTradeScreen.Side.ButtonBUY'.", repo.PlaceTradeScreen.Side.ButtonBUYInfo)
        	   repo.PlaceTradeScreen.Side.ButtonBuy.Press()
        	ElseIf repo.PlaceTradeScreen.OrderShareTotal.RowRow_1.CellFirm_Total_row_0.Text <0 Then
        	   Report.Log(ReportLevel.Info, "Invoke Action", "Invoking Press() on item 'PlaceTradeScreen.Side.ButtonCVS'.", repo.PlaceTradeScreen.Side.ButtonCVSInfo)
        	   repo.PlaceTradeScreen.Side.ButtonCVS.Press()
        	ElseIf repo.PlaceTradeScreen.OrderShareTotal.RowRow_1.CellFirm_Total_row_0Info.Exists == False Then
        	   Report.Log(ReportLevel.Info, "Invoke Action", "Invoking Press() on item 'PlaceTradeScreen.Side.ButtonBUY'.", repo.PlaceTradeScreen.Side.ButtonBUYInfo)
        	   repo.PlaceTradeScreen.Side.ButtonBuy.Press()
        	End If

Re: User code with If and ElseIf

Posted: Fri Mar 30, 2012 12:21 pm
by Support Team
Hi,

The clause where you check if the cell exists have to be the first one, because otherwise if the cell doesn't exist you will get a failed to find item error message.

Regards,
Markus
Ranorex Support Team