VBScript - Dynamic Arrays

Results 1 to 2 of 2

Thread: VBScript - Dynamic Arrays

  1. #1
    Join Date
    Dec 1969

    Default VBScript - Dynamic Arrays

    Hello,<BR><BR>I&#039m trying to use a dynamic array. I have firstly created the array Dim bookedarray(), then When I have worked out how big the array is going to be, I redim it to that size. I keep makeing the array bigger as I need to put more things in it. The only problem is, what I put orginally goes misseing. Heres what I&#039m doing. Where am I going wrong?<BR><BR>&#060;%inv=Request.Form("inv")<BR>da tefrom=Request.Form("datefrom")<BR>daysfor=Request .Form("daysfor")<BR>Dim bookedarray(100)<BR>aa=0<BR>%&#062;<BR>&#060;%<BR> fp_sNoRecords = "&#060;h3 align=&#039center&#039&#062;No Record Returned&#060;/h3&#062;"<BR>query="Select * from Reservations where [InvNo] = "+inv<BR>set rs = server.createobject("ADODB.Recordset")<BR>rs.open query, "DSN=boils",0,3<BR><BR><BR>If rs.EOF And rs.BOF Then<BR> Response.Write fp_sNoRecords<BR>Else<BR>do while not rs.eof<BR>dater=rs.fields("Date of Reservation")<BR>days=rs.fields("Days of Loan")<BR>test=test+days<BR>Redim bookedarray(test+days)<BR>For i = 1 to days<BR> bookedarray(aa)=DateValue(dater)<BR> dater=dater+1<BR> aa=aa+1<BR>Next<BR><BR>rs.MoveNext<BR>Loop<BR>rs.M oveFirst<BR>end if%&#062;<BR>

  2. #2
    rajit Guest

    Default RE: VBScript - Dynamic Arrays

    pretty simple!<BR><BR>when you are REDIMing your array, you are loosing all the preset data. use have to use the keyword "PRESERVE"<BR><BR>ex:<BR>dim ary1()<BR>&#039code<BR>redim preserve ary1(10)<BR>&#039code<BR>redim preserve ary1(20)<BR><BR><BR><BR>

Posting Permissions

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