473,503 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

classic asp byRef vs. byBal

JT
what is the default behavior of asp for passing values to a function, byRef
or byVal? i was under the assumption that if you do not specify, then it
defaults to passing the parameter byRef.

so for example, the following function is accepting param1 and param2 as
"byRef" parameters:

function myFunction(param1,param2)
'do something
end function
am i correct?

thanks,

jt
Oct 20 '05 #1
2 6784
JT wrote:
what is the default behavior of asp for passing values to a function,
byRef or byVal? i was under the assumption that if you do not
specify, then it defaults to passing the parameter byRef.

so for example, the following function is accepting param1 and param2
as "byRef" parameters:

function myFunction(param1,param2)
'do something
end function
am i correct?


It depends on how you call the function. The default is byref, but the
method used to call the function can override this. Specifically, enclosing
an argument in parentheses when not consuming the return value will force it
to be passed by value (sort of):

function test(arg)
arg=arg + 1
test=arg
end function

val = 1

response.write "Return value discarded, parens not used: " & _
val & "<BR>"
test val
response.write val & "<BR>"

val=1
test(val)
response.write "Return value discarded, parens used: " _
& val & "<BR>"

val=1
newval=test(val)
response.write "Return value used, parens used: " _
& val & "<BR>"


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Oct 20 '05 #2
"JT" <jt@nospam.com> wrote in message
news:eu**************@TK2MSFTNGP14.phx.gbl...
what is the default behavior of asp for passing values to a function,
byRef or byVal? .. . . i was under the assumption that if you do not specify, then it defaults
to passing the parameter byRef.


Correct.

HTH,
Phill W.
Oct 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
383
by: Sandy | last post by:
Hello! Help!!!! I have ten zillion books that attempt to describe the difference between ByVal and ByRef and none of them are clear to me. I have gathered that ByVal makes a copy and ByRef...
10
4404
by: Logico | last post by:
Hi everybody, I've tried to use the byref keyword for passing arguments to subroutines and functions in my ASP pages with VBScript, but it seems that both byref and byval are irrilevant, as simple...
6
9035
by: Cc | last post by:
hi, is there a way to use byref on property set , because i would like to pass the value into the variable byref ?
7
5491
by: Hei | last post by:
Hi, i know the difference of ByRef and ByVal, in case if use byref or byval don't affect the result which one should prefer? (less memory use, better performance ....issue) thx
19
2394
by: Rob Panosh | last post by:
Hello, Ok here is the senerio: ..... Dim myArrayList as New ArrayList(0) me.Test_A( myArrayList )
4
12289
by: Carlos Gomez | last post by:
In VB6 the default for passing variables was ByRef. It was faster and used less memory. Why did MS changed that? Are there any advantages using ByVal over ByRef? (other than ByVal impeding you from...
3
1391
by: ItsMe | last post by:
Hi Guyz, I'm developing some application using third party api. They have given me sample project which is in VB6.0. I'm a newbie in vb.net. and the classic vb works perfectly alright. My job is...
4
2443
by: Warren Sirota | last post by:
Hi, Please let me know if I am interpreting this correctly. I've done a little testing of the difference between passing parameters byVal and byRef, and the results were slightly non-intuitive,...
6
1943
by: ari | last post by:
hey all, i have the following 2 classes: Public Class DataAccessLayer .... .... Public Sub GetRecords(ByRef ds As DataSet1) ds = New DataSet1
0
7198
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6979
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4998
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
373
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.