Funzione UBound

Restituisce il limite superiore di una matrice.

Sintassi:


UBound (NomeMatrice [, Dimensione])

Valore restituito:

Integer

Parametri:

NomeMatrice: nome della matrice per la quale desiderate determinare il limite superiore (Ubound) o inferiore (LBound).

[Dimension]: numero intero che specifica per quale dimensione deve essere restituito il limite superiore (Ubound) o inferiore (LBound). Se non viene specificato un valore, viene restituito il limite della prima dimensione.

Codici di errore:

5 Richiamo di procedura non valido

9 Indice al di fuori dell'area definita.

Esempio:


Sub ExampleUboundLbound
Dim sVar(10 To 20) As String
    Print LBound(sVar())
    Print UBound(sVar())
End Sub
 
Sub ExampleUboundLbound2
Dim sVar(10 To 20,5 To 70) As String
    Print LBound(sVar()) ' Restituisce 10
    Print UBound(sVar()) ' Restituisce 20
    Print LBound(sVar(),2) ' Restituisce 5
    Print UBound(sVar(),2) ' Restituisce 70
End Sub