简体   繁体   English

在for循环中填充VBScript数组

[英]Filling in a VBScript array in a for loop

I'm attempting to create and fill in a two-dimensional array in VBScript, which resides in an ASP page. 我正在尝试在VBScript中创建并填充二维数组,该数组驻留在ASP页面中。 I have the following code: 我有以下代码:

Dim array(11, 6)

For record = 0 To 6
    array(6, record) = 8
    array(7, record) = "test"
Next

array(6, 3) = 8
array(7, 3) = "test"

The for loop doesn't work, though. 但是for循环不起作用。 Nothing gets filled in. If I do it explicitly, like the code after the loop, that works just fine. 什么都没有填写。如果我明确地这样做,就像循环后的代码一样, 很好。

I've hardly ever used VBScript before but this seems like it should work. 我之前几乎没有使用过VBScript,但这似乎应该可行。 Why is my loop not doing anything? 为什么我的循环没有做任何事情?

Your "doesn't work" doesn't work. 你的“不工作”不起作用。 You'll have to describe exactly what you expect and what happens instead. 你必须准确描述你的期望和发生的事情。 Otherwise - 除此以外 -

Dim a(11,6)
For i = 0 To 6
    a(6,i) = i
    a(7,i) = "test"
Next
WScript.Echo a(6,0),a(7,0)
WScript.Echo a(6,6),a(7,6)

0 test
6 test

Is there an evil "On Error Resume Next" active? 有一个邪恶的“On Error Resume Next”有效吗?

WRT the OERN: 写下OERN:

You could insert an "On Error GoTo 0" immediately before the critical/new code and continue driving with your eyes shut with an "On Error Resume Next" immediately after it. 您可以在关键/新代码之前插入一个“On Error GoTo 0”,然后立即关闭,并在其后立即关闭“On Error Resume Next”。

Or: copy the new code into a clean/empty .vbs to be used by cscript.exe 或者:将新代码复制到cscript.exe使用的干净/空.vbs中

Or: post the relevant part of the code completely. 或者:完全发布代码的相关部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM