title: How to store loop result into array in VBScript?
body: <p>I have a loop, and I want to put the result into array.
  Here is my loop.</p>
  
  <pre><code>    For i = 1 To bill
          a = rs("CT08_Tarikh") 'from db
          cutiumum = Array(a)   'and this is how I declare array
          rs.MoveNext
      Next
      rs.Close
      Set rs = Nothing
  End If
  </code></pre>
  
  <p>and after that, i will pass the variable to another function:</p>
  
  <pre><code>tarikh = NetWorkdays(dateFrom, dateTo, cutiumum)
  
  Public Function NetWorkdays(dtStartDate, dtEndDate, arrHolidays)
  </code></pre>
  
  <p>but, when I try to do some loop for <code>arrHolidays</code> inside the function <code>NetWorkdays</code>, it only return 1 data (not all from the <code>cutiumum</code>).</p>
  
  <p>What do you think is my mistake?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I'm already using </p>
  
  <pre><code>dim arrRecordset
  
  arrRecordset = rs.GetRows()
  </code></pre>
  
  <p>but I got an error inside the function</p>
  
  <pre><code>Public Function NetWorkdays(dtStartDate, dtEndDate, arrHolidays)
      Dim lngDays
      Dim lngSaturdays
      Dim lngSundays
      Dim lngHolidays
      Dim lngAdjustment
      Dim dtTest
      Dim i, x
  
      lngDays = DateDiff("d", dtStartDate, dtEndDate)
      lngSundays = DateDiff("ww", dtStartDate, dtEndDate, vbSunday)
      lngSaturdays = DateDiff("w", IIf(Weekday(dtStartDate, vbSunday) = vbSaturday, dtStartDate, dtStartDate - Weekday(dtStartDate, vbSunday)), dtEndDate)
  
      For x = LBound(arrHolidays) To UBound(arrHolidays)
          For i = 0 To lngDays
              dtTest = DateAdd("d", i, dtStartDate)
  
  'error in line here: Subscript out of range: 'arrHolidays'
              If arrHolidays(x) = dtTest And Weekday(dtTest) &lt;&gt; 1 And Weekday(dtTest) &lt;&gt; 7 Then
                  lngHolidays = lngHolidays + 1
              End If
          Next
      Next
  
      If Weekday(dtStartDate, vbSunday) = vbSunday Or Weekday(dtStartDate, vbSunday) = vbSaturday Then
          lngAdjustment = 0
      Else
          lngAdjustment = 1
      End If
  
      NetWorkdays = lngDays - lngSundays - lngSaturdays - lngHolidays + lngAdjustment
  End Function
  </code></pre>