Maf Kazama Maf Kazama - 2 years ago 101 Question

How to count value in array with exception?

I have an array that having integer value,

Dim array1() As Integer = New Integer() {14,12,0,4,25,0}

I would like to count except zero number, hope the result is
. I was try to find the article in the internet but almost isn't exception.

Answer Source

I used a Lambda Expression and .FindAll:

    Dim array1() As Integer = New Integer() {14, 12, 0, 4, 25, 0}
    Dim matchedItems() As Integer = Array.FindAll(array1, _
                                        Function(x) x > 0)

It will find all items within the array where the item is > 0.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download