views:

558

answers:

2

Hi all, I would like to print out the data, for debugging purpose.

Data format would be like this

 cntryCode  = resArray("COUNTRYCODE")
 business  = resArray("BUSINESS") ' Payer's business name.
 shipToName  = resArray("SHIPTONAME")

the resArray consist of more than 10 records itself.

I tried to print out, but fail.

version 1 not working

public sub prArray (myarr)
    Dim x, ResponseData
    For x = 0 to myarr.Count
        ResponseData = ResponseData & myarr.Key(x) & " = " & myarr.Item(x) & "<br>"
    Next
    Response.Write ResponseData
end sub

version 2 also not working

public sub prArray (myarr)
    Dim x, ResponseData
    For x = 0 to UBound(myarr)
        ResponseData = ResponseData & myarr(x) & " = " & myarr(x) & "<br>"
    Next
    Response.Write ResponseData
end sub

I believe sure got some way to print out in classic asp

+1  A: 

You are using a Scripting.Dictionary no doubt. It is not ordered use this:-

 Sub prArray(myArr)
     Dim key
     For Each key in myArr
         Response.Write key & " = " & myArr.Item(key) & "<br />"
     Next
 End Sub
AnthonyWJones
thanks, your solution works.
i need help
A: 

What type is resArray? Is it a Collection? From the first code section, it looks like you access the items by key, so it can't be a simple array..? Can you give code example of how resArray is declared and populated?

If the collection is 0 base it will be:

For x = 0 to myarr.Count - 1

If the collection is 0 base it will be:

For x = 1 to myarr.Count

If it is a basic array, and you don't know what index base it is:

For x = LBound(myarr) to UBound(myarr)
awe