If I have the following array:
    Dim Array(4, 10) As String
    Array(0, 0) = "100"
    Array(0, 1) = "200"
    Array(1, 0) = "300"
    Array(1, 1) = "400"
    Array(1, 2) = "500"
    Array(1, 3) = "600"
How do I get the following count:
0 = 2
1 = 4
                It sounds like you're trying to count the number of non-Nothing values in each dimension of the array.  The following function will allow you to do that
Public Function CountNonNothing(ByVal data As String(,), ByVal index As Integer) As Integer
    Dim count = 0
    For j = 0 To data.GetLength(1) - 1
        If data(index, j) IsNot Nothing Then
            count += 1
        End If
    Next
    Return count
End Function
And it can be invoked like so
Dim count1 = CountNonNothing(Array, 0)
Dim count2 = CountNonNothing(Array, 1)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With