Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays VBS使用变量字符串引用数组名称会导致类型不匹配';ubound';代码:800A000D_Arrays_Variables_Vbscript - Fatal编程技术网

Arrays VBS使用变量字符串引用数组名称会导致类型不匹配';ubound';代码:800A000D

Arrays VBS使用变量字符串引用数组名称会导致类型不匹配';ubound';代码:800A000D,arrays,variables,vbscript,Arrays,Variables,Vbscript,我有40个数组,例如,arrOne、arrTwo、arrTwo,等等。因此: Dim arrOne arrOne = Array("word","Cat","Dog","Bob") ' I can lbound and ubound this array... **BUT!!!** strChooseOne = "arrOne" For I = 0 to ubound(strChooseOne) ' ***do stuff*** Next 这将导致一个错误: 类型不匹配“uBond

我有40个数组,例如,arrOnearrTwoarrTwo,等等。因此:

Dim arrOne

arrOne = Array("word","Cat","Dog","Bob")

' I can lbound and ubound this array... **BUT!!!**

strChooseOne = "arrOne"

For I = 0 to ubound(strChooseOne)

' ***do stuff***

Next
这将导致一个错误:

类型不匹配“uBond”
代码:800A000D

可能是因为strChooseOne是一个包含“arrOne”的字符串变量,而arrOne是一个实际数组

我需要循环通过500项,这将引用40个数组中的1个,以任何顺序。。。我宁愿不必重复“do stuff代码40次,检查每个数组。。。 我想用这个。。。下一个循环代码一次,每次通过


我在谷歌上搜索了错误代码,但似乎没有任何相关信息。

看看下面的示例:

选项显式
暗阿达塔
暗aTmp
昏暗的我
Dim j
暗淡的
'使用随机元素数量的40个嵌套数组填充主数组
随机化
雷迪姆·阿达塔(39)
对于i=0到39
aTmp=Array()
做
重读保存aTmp(UBound(aTmp)+1)
aTmp(UBound(aTmp))=“[”和右(“0”&i,2)和Chr(65+UBound(aTmp))&“”
循环直到Rnd>0.55
aData(i)=aTmp
下一个
'使处理成为您需要的
s=“”
对于i=0到39
对于j=0到UBound(aData(i))
“***做事***
s=s&aData(i)(j)
下一个
s=s&vbCrLf
下一个
回音

您需要嵌套数组。40?哇,这是一个很大的开销。像@ OMGESPARIPS已经建议您可能考虑使用嵌套数组或<代码>脚本>字典<代码>。错误是因为<代码> UBEnter()>代码>期望一个<代码>数组< /C>变量,但是它通过了<代码>字符串< /代码>。如果要动态计算数组变量,需要使用
Eval()
计算字符串中的变量名。