Split Value and make addition of value

Hi All,

I have a variable value Ex- “1900.20 450.30” I want to split it and want addition 1900.20+450.30.

I have write invoke code for this. When I am trying to run it Continue basis. I am finding the below error.


Message : Exception has been thrown by the target of an invocation.

Exception Type: System.Reflection.TargetInvocationException

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ----> System.FormatException: Input string was not in a correct format.

at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)

at System.Convert.ToDouble(String value)

at UiPathCodeRunner_c0e165ff380e43a3b4c8caba5dc849d3.Run(String To_Pay, Double& Fast_Pay_Discount)

— End of inner ExceptionDetail stack trace —

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object arguments, Signature sig, Boolean constructor)

at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object parameters, Object arguments)

at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture)

at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object providedArgs, ParameterModifier modifiers, CultureInfo culture, String namedParams)

at UiPath.Core.Activities.Workflow.CompilerRunner.Run(Object args)

at UiPath.Core.Activities.InvokeCode.Execute(CodeActivityContext context)

at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)

at System.Activities.ActivityInstance.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

It would be Great if i found the solution.

Arry = Text.split(yourstring," ")
Addition =0
Foreach item in Arry
Addition = addition +convert.todouble(item)

1 Like

one of possible solutions:

(split("1900.20 450.30"," "c).AsEnumerable().Sum(Function(c) Cdbl(c))).ToString


Hi madsps,

Thanks for you response…
I used your solution with my variable.like below and my variable type is string.

Variable= (split(Variable," "c).AsEnumerable().Sum(Function© Cdbl©)).ToString I am using it in assign

BUT I am facing the error. Please help me on this.


Try this One

StrInput.Split({" "},stringSplitOptions.None).ToList.Where(Function(x) IsNumeric(x)).Sum(Function(x) Convert.ToDouble(x.ToString)).ToString



Hi Mahesh1,

Thanks For the help now its working fine. :slight_smile:

Resolved @Mahesh