返回?cái)?shù)組元素的總數(shù).
UBound ( 數(shù)組 [, 維數(shù)] )
Array | 數(shù)組變量. |
維數(shù) | [可選參數(shù)] 指定返回多維數(shù)組的哪個(gè)維數(shù). 默認(rèn)值為 1, 表示第一維. 若此參數(shù)為 0, 則返回?cái)?shù)組的下標(biāo)數(shù)(維數(shù)). |
成功: | 返回?cái)?shù)組維數(shù)的大小. |
失敗: | 返回 0, @error 設(shè)置為: |
1 = 給定的"數(shù)組"并非數(shù)組. | |
2 = 數(shù)組維數(shù)無效. |
Local $myArray[10][20] ;元素 0,0 到
9,19
Local $rows
= UBound($myArray)
Local $cols
= UBound($myArray, 2)
Local $dims
= UBound($myArray, 0)
MsgBox(0, "當(dāng)前
" & $dims & "
維數(shù)組有", _
$rows & "
行, " & $cols & "
列")
;顯示 $myArray 內(nèi)容
Local $output
= ""
For $r = 0 To
UBound($myArray, 1) -
1
$output = $output & @LF
For
$c = 0 To UBound($myArray, 2) -
1
$output = $output & $myArray[$r][$c] & " "
Next
Next
MsgBox(4096, "數(shù)組內(nèi)容", $output)
provider with jb51.net (unicode) |