VB6 in the reference pass with VB. The difference between reference passing in net

Source: Internet
Author: User

First of all, note that the default parameter in VB6 is passed as a reference pass, whereas the default parameter in vb.net is passed by: value passing.

Then we look at the reference passing in the following VB6 in contrast to the reference passing in the vb.net.

Reference passing in the VB6

Private Sub CommandButton1_Click () changename commandbutton1.caption End Sub Private Sub  as String  "namehasbeenchanged! " End Sub

After clicking the button

Vb. NET for reference passing

 Public ClassForm1Private SubButton1_Click (Sender as ObjectE asEventArgs)HandlesButton1.Click changename (button1.text)End Sub     Private SubChangeName (ByRefCaption as String) Caption="namehasbeenchanged!"     End Sub End Class

After clicking the button

From the comparison above, it is found that the effect of reference passing in VB6 is very different from that of reference in vb.net: the same way that the property of a button is passed to the method body as a parameter, and is changed in the method body, but the effect is quite distinct. The caption of the button in VB6 has not been changed, and the text of the button in vb.net has been changed.

In VB6, when a property of an object is passed in a reference pass, the value of the object's property is not changed, but in vb.net, the value of the object's properties is changed when the property of the object is passed as a reference.

This should be particularly noticeable in the VB6 upgrade to VB.net project, where many bugs originate.

VB6 in the reference pass with VB. The difference between reference passing in net

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.