ByRef or ByValue

Results 1 to 2 of 2

Thread: ByRef or ByValue

  1. #1
    Join Date
    Dec 1969

    Default ByRef or ByValue

    I&#039;ve read about using ByRef or ByValue within a function declaration, but I&#039;ve seen some disturbing behavior by arrays as well. It appears that when I try to add a value from an object to an array thus:<BR>------------------------------------------------------------<BR>Dim myarray(5)<BR>set fivethings=server.create("ADODB.RecordSet")<BR>que ry="select * from fivecolumntable"<BR><BR> query, connection, adopenstatic, adlockreadonly, adcmdtext<BR><BR>myarray(0)=fivethings("firstcolum n")<BR>myarray(1)=fivethings("secoondcolumn")<BR>m yarray(2)=fivethings("thirdcolumn")<BR>myarray(3)= fivethings("fouthcolumn")<BR>myarray(4)=fivethings ("fifthcolumn")<BR><BR>-----------------------------------------------<BR><BR>It appears that only the pointers to the values are stored in the array. Then if I close the object to free memory, the values disappear and I get errors in my script.<BR><BR>Is there a way to explicitly define a value assisgnment by copy other than:<BR>----------------------------------------------------------<BR>myvalue=fivethings("firstcolumn")<BR>myarray(0 )=myvalue<BR>----------------------------------------------------------<BR>This seems awfully cumbersome when dealing with large objects.<BR><BR>Can someone explain the best practices for such a thing?

  2. #2
    Join Date
    Dec 1969

    Default I'm surprised...

    I would have expected this behavior in server-side JS, but not in VBS.<BR><BR>But I *think* there&#039;s an easy answer. You&#039;ll have to try it:<BR><BR>myarray(0)=fivethings("firstcolumn").Value<BR><BR>**********<BR><BR>I *HAVE* to ask: Why are you using this clumsy way to transfer data from RS to array? Why aren&#039;t you using GetRows()?<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