Pass arguments ByVal or ByRef 
Author Message
 Pass arguments ByVal or ByRef

I am assisting in the design of an n-tiered application (upgrading an MS
Access App).  We migrated the queries to SQL Server 7 as stored procs and I
created a class to execute the procedure using ADO.  The class has been
compiled into a DLL and placed in an MTS package.  It is working as it
should... so far.

My Question:
When I pass arguments, such as the RecordID number or the field values for
an update or insert, should they be passed ByVal?  Would doing so provide a
significant return for an application on a LAN with 100 users?  How about if
it was only 10 users?

My UI code looks something like this

Dim obj as New GotMilk
Dim rst as ADODB.Recordset

   Set rst = obj.GetMyRecord(1234)
   If rst.BOF and rst.EOF Then
      'Do nothing, no record returned
   Else
      'Process Record
   End if
   Set rst = nothing
   Set obj = nothing

Here I'm only passing the RecordID number, but what about when I have to
pass 6-10 arguments, corresponding to the fields required in order to insert
a record?  Is there a performance hit to pass those arguments ByRef?

Danny Lesandrini



Sat, 26 Jan 2002 03:00:00 GMT  
 Pass arguments ByVal or ByRef
On Tue, 10 Aug 1999 17:32:31 -0600, "Danny Lesandrini"

Quote:

>Here I'm only passing the RecordID number, but what about when I have to
>pass 6-10 arguments, corresponding to the fields required in order to insert
>a record?  Is there a performance hit to pass those arguments ByRef?

Why not test it? Compile two versions of your program and DLL and do
some timed loops. Personally I find it easier to pass everything byVal
unless I specifically want to alter the parameter variables inside the
function call or am passing arrays, and there is supposed to be some
performance benefit as well (I have never tested it though).


Sun, 27 Jan 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Event Arguments : ByRef or ByVal (Which Best)?

2. Passing Parameters - A ByRef vs ByVal Question

3. Passing parameters ByRef or ByVal

4. Passing arguments ByRef from VBScript to COMAdmin component

5. Passing arguments ByRef to Script Control 1.0

6. Passing arguments byref to a class

7. Property Let argument ByRef is NOT ByRef ?

8. Override ByRef with ByVal

9. ByVal / ByRef

10. byVal vs ByRef

11. Questions regarding objects, assignments, byval, byref, etc...

12. Change Standard from ByVal to ByRef

 

 
Powered by phpBB® Forum Software