Friday, August 19, 2011

number of row corrected


i did not change this sub the right way
my catch was bad, now it's ok

the ubound fonction will return an error id you chek the number of elements in the second dimension and there is only one line in the array

so if there is only one line we return the number of line of the first dimension, not the second


    '=== count the number of record in the array
    Function cnttotrec(ByVal aara As Array)
        Dim aa As Integer


        xmax = UBound(aara, 1) 'Returns the Number of columns  --- elements in first dimension
        '=== chek the number of elements in second dimension
        '=== if there is none, then the array have only 1 row
        Try
            ymax = UBound(aara, 2) 'Returns the Number of rows     --- elements in second dimension
            aa = ymax
        Catch ex As Exception
            aa = xmax
        End Try


        '=== number of dimensions in case there is only 1 column
        Return (aa)
    End Function

No comments:

Post a Comment