What variable types should I use containing both numbers and strings, and how to multiply only the numbers?

Hello all need help,- I have list with different things, like numbers and words. egxample: 1, 2, “Ram”, 3, 4, “Bob”, 5, 6. I want to take only numbers from list and multiply all of them. What type of variable I use for this list? And what var type for result?
– How can I do filtering numbers and multiply in UiPath without error?

thanks in advance. pls help fast.

Hi @RPA_Learner0

use a variable of type List(Of Object) to hold the mixed list. For the result, use an Int32 or double variable depending on whether you expect whole numbers or decimals.

Nowfor result, apply the OfType(Of Int32) method on the list to get only integers, then use Aggregate to multiply all elements,
something like this: YourList.OfType(Of Int32)().Aggregate(Function(acc, x) acc * x).
Pls modify accordingly and try first.

If you need worflow, let me know

thanku sir for hint, Let me try .

Check this,

1 Like

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