Search code examples
htmlarraysstringasp-classic

output array multiples of 8


I have a string which I have split by a comma delimeter and added to an array, now I need to sort the array in multiples of eight for addresses, the first eight will be first address, next eight will be next address and so on.. to be output in a html table. suggestions

like this..

id        addr1         addr2         addr3         add4
1         12 road       birmingham    westmid       u.k

objSoapClient.serviceForPostcodeStringBuilder("AB10 1AF") returns the string.

<%
dim address
dim addArray

SET objSoapClient = Server.CreateObject("MSSOAP.SoapClient")
 objSoapClient.ClientProperty("ServerHTTPRequest") = True

Call objSoapClient.mssoapinit("http://ip address:56478/postcode/Service1.asmx?WSDL","Service1")
response.write(session("collp"))
address = objSoapClient.serviceForPostcodeStringBuilder("AB10 1AF")
addArray = Split(address,",")

%>

Solution

  • On the assumption that addArray has an element count that is a multiple of 8.

    Dim i
    For i = 0 To UBound(addArray) Step 8
        %><tr><td><%=addArray(i)%></td><td><%=addArray(i+1>%></td><td><%=addArray(i+2)%></td></tr><%
    Next
    

    The key feature here is the Step 8 in the for loop..