Sum of array if x not empty

I have arr_Visits and I want to sum it. But it throw exception as it contains “”. How do I modify the expression to sum not empty string only?.

image

image

Hey

give a try with

youArray.Where(Function(x) Not String.IsNullOrEmpty(x)).Sum(Function(s) CDbl(s)).ToString()

Regards

It might be better to get rid of all the non-numeric items.

arr_Visits.Where(Function(s) Double.TryParse(s, New Double)).Sum(Function(s) CDbl(s))

Regards,

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