Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Advanced
Jul 20, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Passing Objects ByVal in VB

You can pass Object parameters to a sub ByVal just as you pass other parameters. But what is the difference between passing Objects ByVal and ByRef, since an object variable always contains a reference to the object in memory and not the object itself?

An object parameter passed ByVal behaves in a similar fashion as any other parameter passed ByVal. The changes made to them inside the called sub procedure are not visible in the calling program. But the fact that the object variable only contains the reference to the actual object makes it more complex. For example:
Public Sub ub TestProc(ByVal ObjVal As cTest, ByRef objRef As cTest)
  dim objNew as new cTest

  objVal.Prop = 
Jatin Shah
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date