在 for 循环中填充 VBScript 数组

发布于 2024-12-03 02:26:15 字数 369 浏览 0 评论 0原文

我试图在 VBScript 中创建并填充一个二维数组,该数组驻留在 ASP 页面中。我有以下代码:

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"

但是 for 循环不起作用。没有任何内容被填充。如果我明确地执行此操作,就像循环后的代码一样,就可以正常工作。

我以前几乎没有使用过 VBScript,但这似乎应该可以工作。为什么我的循环没有执行任何操作?

I'm attempting to create and fill in a two-dimensional array in VBScript, which resides in an ASP page. 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. 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. Why is my loop not doing anything?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2024-12-10 02:26:15

你的“行不通”行不通。您必须准确描述您的期望以及发生的情况。否则 -

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

是否存在邪恶的“On Error Resume Next”活动?

WRT OERN:

您可以在关键/新代码之前插入“On Error GoTo 0”,然后闭上眼睛继续驾驶,并在其后立即插入“On Error Resume Next”。

或者:将新代码复制到干净/空的 .vbs 中以供 cscript.exe 使用

或者:完整发布代码的相关部分。

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?

WRT the 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.

Or: copy the new code into a clean/empty .vbs to be used by cscript.exe

Or: post the relevant part of the code completely.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文