Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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.

 

 

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