VBA UBound & LBound -funktioner

UBound Beskrivelse

Returnerer det højeste abonnement for en dimension af en matrix.

Enkle UBound -eksempler

1234 Under UBound_Example ()Dim a (3 til 10) som heltalMsgBox UBound (a)Afslut Sub

Resultat: 10

UBound Syntax

1 UBound (ArrayName, [Dimension])

UBound -funktionen indeholder 2 argumenter:

Matrixnavn: Navn på Array -variabel.

Dimension: [Valgfrit] Heltal, der angiver, hvilken dimensions nedre grænse der returneres. Brug 1 til den første dimension, 2 til den anden osv. 1 hvis den er udeladt.

Eksempler på Excel VBA UBound -funktion

1234567 Under UBound_Example1 ()Dim arrVærdi (1 til 5, 4 til 8, 12 til 25)MsgBox UBound (arrValue)MsgBox UBound (arrValue, 1)MsgBox UBound (arrValue, 2)MsgBox UBound (arrValue, 3)Afslut Sub

Resultat: 5, 5, 8, 25

LBund Beskrivelse

Returnerer det laveste abonnement for en dimension af en matrix.

Enkle LBound -eksempler

1234 Sub LBound_Example ()Dim a (3 til 10) som heltalMsgBox LBound (a)Afslut Sub

Resultat: 3

LBundt syntaks

1 LBundt(ArrayName, [Dimension])

LBound -funktionen indeholder 2 argumenter:

Matrixnavn: Navn på Array -variabel.

Dimension: [Valgfrit] Heltal, der angiver, hvilken dimensions nedre grænse der returneres. Brug 1 til den første dimension, 2 til den anden osv. 1 hvis den er udeladt.

Eksempler på Excel VBA LBound -funktion

1234567 Sub LBound_Example1 ()Dim arrVærdi (1 til 5, 4 til 8, 12 til 25)MsgBox LBound (arrValue)MsgBox LBound (arrValue, 1)MsgBox LBound (arrValue, 2)MsgBox LBound (arrValue, 3)Afslut Sub

Resultat: 1, 1, 4, 12

wave wave wave wave wave