LOOPING FOR EACH IN INVOKE CODE

INVOKE CODE ( Using For Each Loop )

Value can’t be Null

Hi @Krishan_Rapswal,

Try using the below code and see if it works.

For Each row As DataRow In Dt2.Rows
row(“Sign”) = CDbl(row(“amount”).tostring)*-1
row(“percent”) = CDbl(row(“sign”).tostring)*10
row(“total”) = CDbl(row(“percent”).tostring)-CDbl(row(“sign”).tostring)
Next


Hi @Krishan_Rapswal,

add this try catch block to get an exact information of the error

Try
For Each row As DataRow In Dt2.Rows
row(“Sign”) = CDbl(row(“amount”).tostring)*-1
row(“percent”) = CDbl(row(“sign”).tostring)*10
row(“total”) = CDbl(row(“percent”).tostring)-CDbl(row(“sign”).tostring)
Next
Catch e As Exception
console.WriteLine(e)

Hi @Krishan_Rapswal,

Sorry, please add end try at the end of the code

Regards.


Hi @Krishan_Rapswal,

The double quote ending in the 4th line after sign is not correct, delete that and add it again and check if it works.

Regards.

Still getting the same error

Hi @Krishan_Rapswal,

Could you share the screenshot of the code

Regards,
RPA Team.

Why are we using Invoke Code?
We can use direct for each row UiPath commands

directly i have done this
but i need to be done through invoke code with looping

Add Try at the First line like below. It shoudh fix that try error

image

Check End Try is present at the end of the code

Follow the structure in my previous screenshot

Try
Your Code
Catch e As Exception
Your code
End Try

Hi @Krishan_Rapswal,

try this code -

Try
For Each row As DataRow In Dt2.Rows
row(“Sign”) = CDbl(row(“amount”).tostring)*-1
row(“percent”) = CDbl(row(“sign”).tostring)*10
row(“total”) = CDbl(row(“percent”).tostring)-CDbl(row(“sign”).tostring)
Next
Catch e As Exception
console.WriteLine(e)
end try

Hi @Krishan_Rapswal,

could you share the code screenshot please.

Regards