经典 ASP(VB 脚本) 数组 0x800A0009 “下标超出范围错误”
我正在维护一个遗留系统。
我从来没有接触过Classic ASP,而且我的编程知识很少。
您想要对具有二维数组的值进行分组并将它们存储在不同的二维数组中。
我收到数组下标错误,但无法解决问题所在。
有人可以帮助我吗?
== 结果数据 ==
idx | 类型 | pos | 名称 | url | 高度 | 排名 |
---|---|---|---|---|---|---|
9 | A | 顶部 | alex | /citmi | 201 | 15 |
8 | C | left | james | /oftim | 198 | 120 |
7 | A | 底部 | colin | /stici | 170 | 232 |
6 | F | 中 | rhys | /citmi | 183 | 181 |
5 | B | 顶部 | bruce | /奥廷 | 20 | 176 |
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 ==
idx | type | pos | name | url | height | rank |
---|---|---|---|---|---|---|
9 | A | top | alex | /citmi | 201 | 15 |
8 | C | left | james | /oftim | 198 | 120 |
7 | A | bottom | colin | /stici | 170 | 232 |
6 | F | middle | rhys | /citmi | 183 | 181 |
5 | B | top | bruce | /oftim | 20 | 176 |
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论