lbound Method (VBArray)

Returns the lowest index value used in the specified dimension of a VBArray.

语法

safeArray.lbound(dimension)

参数

safeArray

必要参数。A VBArray object.

dimension

可选参数。The dimension of the VBArray for which the lower bound index is wanted. If omitted, lbound behaves as if a 1 was passed.

备注

If the VBArray is empty, the lbound method returns undefined. If dimension is greater than the number of dimensions in the VBArray, or is negative, the method generates a "Subscript out of range" error.

示例

The following example consists of three parts. The first part is VBScript code to create a Visual Basic safe array. The second part is JavaScript code that determines the number of dimensions in the safe array and the lower bound of each dimension. Since the safe array is created in VBScript rather than Visual Basic, the lower bound will always be zero. Both of these parts go into the <HEAD> section of an HTML page. The third part is the JavaScript code that goes in the <BODY> section to run the other two parts.

<head> 
<script type="text/vbscript"> 
<!-- 
Function CreateVBArray() 
  Dim i, j, k 
  Dim a(2, 2) 
  k = 1 
  For i = 0 To 2 
   For j = 0 To 2 
     a(j, i) = k 
     k = k + 1 
   Next 
  Next 
  CreateVBArray = a 
End Function 
--> 
</script> 
<script type="text/javascript"> 
<!-- 
function VBArrayTest(vba){ 
  var i; 
  var a = new VBArray(vba); 
  var s = ""; 
  for (i = 1; i <= a.dimensions(); i++) 
  { 
   s += "The lower bound of dimension "; 
   s += i + " is "; 
   s += a.lbound(i); 
   s += ".<br />"; 
  } 
  return (s); 
} 
--> 
</script> 
</head> 
<body> 
<script type="text/javascript"> 
  document.write(VBArrayTest(CreateVBArray())); 
</script> 
</body>

必备条件

在以下文档模式中受支持:怪异模式、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式和 Internet Explorer 10 标准模式。在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式、Internet Explorer 10标准模式、Internet Explorer 11标准模式。在Windows 8.x应用商店应用中不受支持。请参阅版本信息

Applies ToVBArray Object

如果你喜欢这篇文章,敬请给站长打赏↑

除特别注明外,本站所有文章均为本站站长原译,转载请注明出处。