devxlogo

Passing Objects ByVal in VB

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 =

See also  Digital Signage Solutions for Agile Software Development Teams
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist