VB Judging the number of dimensions

xiaoxiao2021-03-06  108

Design ideas:

The maximum dimension of several sisters in VB is 60, so we caught this problem through the error, here we use the Ubound function.

Public Function ArrayRANRANGE (Marray As Variant) AS INTEGER

DIM I as integer

DIM RET AS INTEGER

Dim Errf as boolean

Errf = false

ON Error Goto Errhandle

'Is it an array of parameters to judge?

IF not isarray (marray) THEN

ArrayRange = -1

EXIT FUNCTION

END IF

The maximum number of VB is 60

For i = 1 to 60

'Judging the upper bound of a certain dimension with the Ubound function, if the actual dimension of the large array is exceeding range errors,

'At this time we capture this error through Resume Next

Ret = ubound (marray, i)

IF Errf THEN EXIT for

Next I

'Final return

ArrayRange = RET

EXIT FUNCTION

Errhandle:

Ret = i - 1

Errf = TRUE

Resume next

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-96375.html

New Post(0)