Set Array size with a variable?

Results 1 to 3 of 3

Thread: Set Array size with a variable?

  1. #1
    Jason Guest

    Default Set Array size with a variable?

    Is it possible to set the size of an array using a variable?<BR>I have this bit of code that retrieves the total number of records found:<BR>vFirst.CursorLocation = 3<BR>vFirst.Open "Members", "DSN=cida" <BR>sqlCount = vFirst.RecordCount<BR><BR>I want to dim an array so that it contains that amount of elements. Ive tried:<BR>dim varArray(sqlCount)<BR>dim varArray( &#039;& sqlCount &&#039;)<BR>dim varArray( & sqlCount & )<BR>Always get the same error message, "Expected Integer Constant"<BR><BR>Thanks

  2. #2
    Richard A. Lowe Guest

    Default RE: Set Array size with a variable?

    2 ways:<BR>&#060;%<BR> &#039; Method One:<BR> intDim = 10<BR> Execute "Dim arrVar(" & intDim & ")"<BR> arrVar(9) = "hello"<BR> Response.Write arrVar(9)<BR><BR> &#039;Method Two:<BR> Dim arrVarTwo()<BR> ReDim arrVarTwo(intDim)<BR> arrVarTwo(9) = " there"<BR> Response.Write arrVarTwo(9)<BR><BR>%&#062;

  3. #3
    Jason Guest

    Default Thanks

    Wish my 3 books would have said that! Thanks

Posting Permissions

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