byref

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

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
 
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
 
Frank said:
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/[email protected]


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
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
 
Frank said:
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.
 
Back
Top