经典 ASP(VB 脚本) 数组 0x800A0009 “下标超出范围错误”

发布于 2025-01-11 10:14:16 字数 2082 浏览 0 评论 0原文

我正在维护一个遗留系统。
我从来没有接触过Classic ASP,而且我的编程知识很少。
您想要对具有二维数组的值进行分组并将它们存储在不同的二维数组中。
我收到数组下标错误,但无法解决问题所在。

有人可以帮助我吗?

== 结果数据 ==

idx类型pos名称url高度排名
9A顶部alex/citmi20115
8Cleftjames/oftim198120
7A底部colin/stici170232
6Frhys/citmi183181
5B顶部bruce/奥廷20176
    strqry = "SELECT idx "
    strqry = strqry& ",type "
    strqry = strqry& ",pos "
    strqry = strqry& ",name "
    strqry = strqry& ",url "
    strqry = strqry& ",height "
    strqry = strqry& ",rank "
    strqry = strqry& "FROM [database].[dbo].[table] "
    strqry = strqry& "WHERE is_apply = 0 "

    dbopen()
    
    Set Rs = Dbcon.Execute(strqry)

Function AddItem(arr, val)
    ReDim Preserve arr(UBound(arr) + 1, 1) '<== Subscript out of range error
    arr(UBound(arr,1)) = val '<= Type error predicted
    AddItem = arr
End Function

Dim listA_1(0,6), listA_2(0,6), listB_1(0,6), listC_1(0,6)

    Do Until Rs.Eof
        ViewNum = CInt(Rs("rank"))
        If ((0 < ViewNum) AND (ViewNum < 80)) Then
            listA_1 = AddItem(listA_1, Rs)
        ElseIf ((80 <= ViewNum) AND (ViewNum < 100)) Then
            listA_2 = AddItem(listA_2, Rs)
        ElseIf ((180 <= ViewNum) AND (ViewNum < 200)) Then
            listB_1 = AddItem(listB_1, Rs)
        ElseIf ((280 <= ViewNum) AND (ViewNum < 300)) Then
            listC_1 = AddItem(listC_1, Rs)
        End If
        Rs.MoveNext
    Loop

I am maintaining an legacy system.
I have never dealt with Classic ASP, and I have little programming knowledge.
You want to group values having a two-dimensional array and store them in different two-dimensional arrays.
I'm getting an array subscript error and I can't fix what the problem is.

Can someone help me?

== Result data ==

idxtypeposnameurlheightrank
9Atopalex/citmi20115
8Cleftjames/oftim198120
7Abottomcolin/stici170232
6Fmiddlerhys/citmi183181
5Btopbruce/oftim20176
    strqry = "SELECT idx "
    strqry = strqry& ",type "
    strqry = strqry& ",pos "
    strqry = strqry& ",name "
    strqry = strqry& ",url "
    strqry = strqry& ",height "
    strqry = strqry& ",rank "
    strqry = strqry& "FROM [database].[dbo].[table] "
    strqry = strqry& "WHERE is_apply = 0 "

    dbopen()
    
    Set Rs = Dbcon.Execute(strqry)

Function AddItem(arr, val)
    ReDim Preserve arr(UBound(arr) + 1, 1) '<== Subscript out of range error
    arr(UBound(arr,1)) = val '<= Type error predicted
    AddItem = arr
End Function

Dim listA_1(0,6), listA_2(0,6), listB_1(0,6), listC_1(0,6)

    Do Until Rs.Eof
        ViewNum = CInt(Rs("rank"))
        If ((0 < ViewNum) AND (ViewNum < 80)) Then
            listA_1 = AddItem(listA_1, Rs)
        ElseIf ((80 <= ViewNum) AND (ViewNum < 100)) Then
            listA_2 = AddItem(listA_2, Rs)
        ElseIf ((180 <= ViewNum) AND (ViewNum < 200)) Then
            listB_1 = AddItem(listB_1, Rs)
        ElseIf ((280 <= ViewNum) AND (ViewNum < 300)) Then
            listC_1 = AddItem(listC_1, Rs)
        End If
        Rs.MoveNext
    Loop

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文