Fonction VBScript LBound

La fonction LBound renvoie le plus petit indice du tableau spécifié. Par conséquent, LBound d'un tableau est ZERO.

Syntaxe

LBound(ArrayName[,dimension])
  • ArrayName, un paramètre obligatoire. Ce paramètre correspond au nom du tableau.

  • dimension, un paramètre facultatif. Cela prend une valeur entière qui correspond à la dimension du tableau. S'il vaut «1», alors il renvoie la limite inférieure de la première dimension; s'il vaut '2', alors il renvoie la limite inférieure de la deuxième dimension et ainsi de suite.

Exemple

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim arr(5)
         arr(0) = "1"            'Number as String
         arr(1) = "VBScript      'String
         arr(2) = 100            'Number
         arr(3) = 2.45           'Decimal Number
         arr(4) = #10/07/2013#   'Date
         arr(5) = #12.45 PM#     'Time

         document.write("The smallest Subscript value of  the given array is : " & LBound(arr))

         ' For MultiDimension Arrays :
         Dim arr2(3,2)
         document.write(
            "The smallest Subscript of the first dimension of arr2 is : " & LBound(arr2,1) & "<br />")
         document.write(
            "The smallest Subscript of the Second dimension of arr2 is : " & LBound(arr2,2) & "<br />")

      </script>
   </body>
</html>

Lorsque le code ci-dessus est enregistré au format .html et exécuté dans Internet Explorer, il produit le résultat suivant:

The smallest Subscript value of the given array is : 0
The smallest Subscript of the first dimension of arr2 is : 0
The smallest Subscript of the Second dimension of arr2 is : 0