Lesson 12 Practice 1 - Try Catch Failure - Assign cashIn = Cint(row("Cash In"))

Hi All,

So… Lesson 12 P 1 :roll_eyes: It might just be me (which it most likely is) but I’m running into an issue when I’m trying my Try Catch. It’s breaking like it’s supposed to but it is giving me the following errors (see below). Am I just a dummy or isn’t it supposed to jump to catches and use my Assign that I have placed there? I thought that was the whole point? Somebody Please Help!


1 Like

Hi @BotMonkey

Use for each row in dataInput

CashIn= Cint(row(“Cash In”).ToString)

Ashwin S

@AshwinS2 You unfortunately can’t use the .ToString as it is supposed to pass it into CashIn which is an Int32 Variable type. Hench the catch. It is supposed to throw it into the result as a string variable, it’s just not passing to the catch as it should. @Mamidi_Sravani @Palaniyappan @lakshman Any help with this?

1 Like

I hope the issue is with the value pass for Parsing like here we have 3B7 as a string which cannot be converted to a integer as it is not full at numerical
It has char B in it
So we can do one thing
Hope these steps would help your resolve this
—use excel application scope and pass the file log excel as input
—inside the scope use Read Range activity and get the output with a variable of type datatable named dt
—now use a assign activity like this
dt = dt.AsEnumerable().Where(Function(row) IsNumeric(row(“Cash In”).ToString.Trim)).CopyToDataTable()

And another assign activity followed by the above
dt = dt.AsEnumerable().Where(Function(row) IsNumeric(row(“Cash Out”).ToString.Trim)).CopyToDataTable()

These two expression will return the datatable variable dt only with those two columns having numerical value in it
—so now use a for each row loop ans pass the datatable variable dt as input
—inside the loop use a assign activity like this
int_Result = Convert.ToInt32(row(“Cash In”).ToString) + Convert.ToInt32(row(“Cash Out”).ToString)

That’s all you are done
Hope this would help you
Cheers @BotMonkey

1 Like

This worked for me.

Turn off Break on Exceptions in the Debug Options

1 Like

@danyeo Great job cadet!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.