please help with this array! im going mad!

Results 1 to 2 of 2

Thread: please help with this array! im going mad!

  1. #1
    Join Date
    Dec 1969

    Default please help with this array! im going mad!

    Hi all,<BR>i am trying hard to passover a form field to a page which adds that to an sql script which generates a result from a strored procedure. anyway the stored procedure sends down a userID that matches the particular form field that is sent over. ie if there are four form fields it sends back four ID&#039s, three, three ids etc etc.<BR><BR>what i need to do is to trap that number being sent down into an array. Which should be a easier enough job. But im having a hellish task of trying to create the array to trap the id number.<BR><BR>and i cant seem to find any GOOD examples of a stored array.<BR>the code below dosnt work...can any body point me or help me to create a basic Array that will store 1 result at a time in a loop. (dont need the loop just a away to create an array.<BR><BR>okay ill stopp waffling...<BR><BR>thanks for your time<BR><BR>Ade Stuart<BR><BR>myarray = new array(i)<BR>For i=1 to Request("TickNum").Count<BR>Transactsql = "Exec Transact " & MemberID & "," & Request.Form.Item(i)<BR>Set rs = Conn.Execute(Transactsql)<BR>myarray(i) = rs.field("basketid")<BR>Response.Write myarray(i)<BR>next

  2. #2
    Steve Cimino Guest

    Default RE: please help with this array! im going mad!

    This line: myarray = new array(i)<BR><BR>is invalid. First, I don&#039t believe you create the array like this in vbscript. You do that in JavaScript.<BR><BR>Second, i contains 0 at this point. What you&#039re saying is create an array with 0 bounds. You should be getting "Subscript out of range" errors all over the place.<BR><BR>Third, arrays are 0 based. You should begin your count at 0 (it&#039s confusing at first I know, but it will become the norm when you gain more experience)<BR><BR>Do this:<BR><BR>Dim myArray() &#039 Initialize array<BR>ReDim myArray(10) &#039 Now we&#039re going to set it&#039s dimensions.. needs to be done this way due to the dynamic size<BR><BR><BR>For i = 0 To Request("ticknum").COunt &#039 I&#039ve never seen this, but I&#039ll assume it&#039s valid<BR><BR>myArray(i) = rs.field("basketid")<BR>&#039Now, if there are more than 10 elements, we want to expand the array<BR><BR>If i % 10 = 0 AND i &#062; 1 Then &#039 We want to expand the array by 10 each time it begins to fill up<BR><BR> Redim Preserve myArray( i + 10 )<BR>End If<BR><BR>Next<BR><BR><BR>Now, let&#039s clean up the blank spaces..<BR><BR>Redim preserve myArray(i)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts