User code with If and ElseIf

Ask general questions here.
byonush
Posts: 7
Joined: Mon Mar 12, 2012 3:53 pm

User code with If and ElseIf

Post by byonush » Thu Mar 29, 2012 3:09 pm

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
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: User code with If and ElseIf

Post by Support Team » Fri Mar 30, 2012 12:21 pm

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