Redims and arrays

Results 1 to 2 of 2

Thread: Redims and arrays

  1. #1
    Join Date
    Dec 1969

    Default Redims and arrays

    We are Using IIS 6.0 and have several asp pages that rely on data from a SQL Database. We have a constantly changing number of personnel, and I constantly have to go in and change an array in the code to reflect the proper number of people added or subtracted. Is there anyway to create an array that uses a variable to specify the number of elements in the array? For example...<BR><BR>dim aa = elementcnt <BR>&#039;elementcnt being the SQL <BR>&#039;generated count of users in a SQL Database<BR><BR>redim persons(aa)<BR><BR>I know that I could make the array with an huge number, but that seems like a waste of resources.<BR><BR>Thanks for any help, in advance.<BR><BR>Rob

  2. #2
    Join Date
    Dec 1969

    Default You answered your own question...

    Yes, <BR> redim persons(aa)<BR>is the correct way.<BR><BR>Or<BR> Redim Preserve persons(aa)<BR>if you don&#039;t want to lose the prior contents of the array.<BR><BR>**BUT**<BR><BR>But I strongly suspect your code is very inefficient if you are doing this.<BR><BR>Have you looked at ADODB.Recordset.GetRows()? So that you could do<BR> allRecords = MyRecordSet.GetRows( )<BR>to convert the entire recordset into a 2D array in one operation?<BR><BR>By the way...making the array have a large number of elements is only mildly wasteful. Unused array elements only "eat" 16 bytes of space. So if you did<BR> Dim persons(1000)<BR>and only used (say) 100 of those array elements, you&#039;d only be<BR>wasting 14,400 bytes of memory...and that only for so long as the page is running.<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