'Classic ASP(VB Script) array 0x800A0009 'Subscript out of range error'

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source