473,320 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

byref

Hi,

in the code below, does it matter, in this case, whether I use byval or
byref? I don't think so but I would like confirmation. In both case I don't
change the actual value of pdgts, just the data it refers to.

Thanks
Frank
Private Sub somesub(ByRef pdgts As DataGridTableStyle, ByVal pds As DataSet)

....somecode..

pdgts.GridColumnStyles.Add(colArt)

End Sub

Nov 20 '05 #1
5 1387
Hi Frank,

From a value is send byvalue the value and from an object(everything else)
is with byval send the reference.

Actualy are you boxing the reference by passing it by reference.

This statement is by instance completly nuts
\\\
private function getdataset(byval ds as dataset) return dataset
return ds
end function
///
I hope this helps?

Cor
Nov 20 '05 #2
"Frank" <fr***@frank.com> schrieb
Hi,

in the code below, does it matter, in this case, whether I use byval
or byref? I don't think so but I would like confirmation. In both
case I don't change the actual value of pdgts, just the data it
refers to.

Thanks
Frank
Private Sub somesub(ByRef pdgts As DataGridTableStyle, ByVal pds As
DataSet)

...somecode..

pdgts.GridColumnStyles.Add(colArt)

End Sub


Yes, it does matter whether you pass ByVal or ByRef.

Call:
dim ds as new dataset
somesub(..., ds)

a) Sub Somesub, using ByVal:
pds = nothing
=> does _not_ change variable ds in the calling procedure because the
argument pds is a copy of the reference to the Dataset
b) Sub SomeSub, using ByRef:
pds = nothing
=> _does_ change variable ds in the calling procedure because the argument
pds is a reference to variable ds in the calling procedure.
ByVal/ByRef does not matter if you manipulate the dataset itself, i.e. the
content of the dataset. In both cases you use pds to access the dataset.

See also:
http://groups.google.com/groups?selm...ews.freenet.de
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Cor and Armin,
I was refering to parm pdgts not parm pds. The statement
pdgts.GridColumnStyles.Add(colArt)
will do exactly the same no matter if parm pdgts is passed byval or byref.
Correct me if I am wrong.
Greets
Frank

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de...
"Frank" <fr***@frank.com> schrieb
Hi,

in the code below, does it matter, in this case, whether I use byval
or byref? I don't think so but I would like confirmation. In both
case I don't change the actual value of pdgts, just the data it
refers to.

Thanks
Frank
Private Sub somesub(ByRef pdgts As DataGridTableStyle, ByVal pds As
DataSet)

...somecode..

pdgts.GridColumnStyles.Add(colArt)

End Sub
Yes, it does matter whether you pass ByVal or ByRef.

Call:
dim ds as new dataset
somesub(..., ds)

a) Sub Somesub, using ByVal:
pds = nothing
=> does _not_ change variable ds in the calling procedure because the
argument pds is a copy of the reference to the Dataset
b) Sub SomeSub, using ByRef:
pds = nothing
=> _does_ change variable ds in the calling procedure because the argument
pds is a reference to variable ds in the calling procedure.
ByVal/ByRef does not matter if you manipulate the dataset itself, i.e. the
content of the dataset. In both cases you use pds to access the dataset.

See also:

http://groups.google.com/groups?selm...2d9e%40news.fr
eenet.de

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4
"Frank" <fr***@frank.com> schrieb
ByVal/ByRef does not matter if you manipulate the dataset itself,
i.e. the content of the dataset. In both cases you use pds to
access the dataset.

See also:

http://groups.google.com/groups?selm...2d9e%40news.fr eenet.de

I was refering to parm pdgts not parm pds. The statement
pdgts.GridColumnStyles.Add(colArt)
will do exactly the same no matter if parm pdgts is passed byval or
byref. Correct me if I am wrong.


My answer can also be applied to pdgts.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
"Frank" <fr***@frank.com> schrieb
Cor and Armin,
I was refering to parm pdgts not parm pds. The statement
pdgts.GridColumnStyles.Add(colArt)
will do exactly the same no matter if parm pdgts is passed byval or
byref. Correct me if I am wrong.
Greets
Frank


I wanted to say: Yes, you are right.
--
Armin

Nov 20 '05 #6

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

Similar topics

8
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
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
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
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
by: Rob Panosh | last post by:
Hello, Ok here is the senerio: ..... Dim myArrayList as New ArrayList(0) me.Test_A( myArrayList )
4
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...
14
by: Robin Tucker | last post by:
Although I've been working on this project for 8 months now, I'm still not sure of the difference between ByVal and ByRef. As most objects in VB are reference types, passing ByVal I've discovered...
4
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,...
7
by: barrett bonden | last post by:
Is there any way to pass parameters to a function and simply know there will get there without the silly (C like ) complexity of worring about byval and or perhaps byref ? (Why bother to...
6
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.