Upgrading VB6 --> .Net 1.1: How to make a property set ByRef?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My VB6 application has some properties which are set ByRef but upgrade to
ByVal. [I read in the documentation that Property SET ByRef is not allowed
in VB.Net] How can I assure that the new code behaves the same as the old?
 
katzky said:
My VB6 application has some properties which are set ByRef but upgrade to
ByVal. [I read in the documentation that Property SET ByRef is not
allowed
in VB.Net] How can I assure that the new code behaves the same as the
old?

How did the old code behave? The only reason I can think of to support ByRef
property assignments would be for array support.

Were you manipulating the values before returning in VB6? If so, that
doesn't seem to work in VB6 either....
'======
Option Explicit

Private msTest As String

Public Property Get Test() As String
Test = msTest
End Property

Public Property Let Test(ByRef Setting As String)
msTest = Setting
'attempt to manipulate the ByRef variable
Setting = "Property has been set"
End Property

Private Sub Form_Load()
Dim s As String

s = "This is a test"

Test = s

'shows "This is a test", instead of the expected "Property has been set"
Debug.Print s

End Sub
'======
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top