Else If doesn't work how it should

The logic here is on row 0 I want to run the Business Days activity. And for any subsequent row where the RUN_DATE value is different from the previous row, also run the Business Days activity. When the first condition is met it shouldn’t bother processing the second condition, but it does anyway.

image

The workaround for this is to change the “Else If - Condition” to: index > 0 AndAlso NOT CurrentRow(“RUN_DATE”).ToString = DT_Main.Rows(index-1)(“RUN_DATE”).ToString

But I shouldn’t have to do that.

Hey Paul, apologies if I’ve misunderstood what you are trying to do but I’ve just tried it and it seems to work on my setup albeit I have much simpler conditions.

Yours works because you aren’t doing what I’m doing. I’m referencing a row index in a datatable, in the second condition. That’s why the error is that row index -1 doesn’t exist. It’s processing the ElseIf even though the first condition is met. Yours is doing the same thing, but your second ElseIf condition can’t error out so you’re not getting an error. Change your second condition to…

dtTest.Rows(intDtIndex -1)(0).ToString = “Something”

Thank you for reporting this one, it indeed looks like it shouldn’t trigger the second condition and it does (I reproduced this quite easily on my end).

1 Like