
Passing an object reference by reference where the object has a default property
Below is
Visual Basic code that demonstrates the problem:
The (custom) Variable object has a default property of Value. I want to
pass in the reference to the object into a subroutine by reference and have
the Value
property changed. The value get changed in VB but not in the Script
control.
Any experience with this?
Dim scrctrl As New ScriptControl
Private Sub Command1_Click()
Dim var As New Variable
var.Name = "MyProp"
var = 4
MsgBox var
Dim codetext As String
codetext = "Sub MySub(x)" & vbCrLf & "x=3" & vbCrLf & "End Sub"
scrctrl.AddCode codetext
scrctrl.AddObject var.Name, var
scrctrl.ExecuteStatement "MySub MyProp"
MsgBox var
MySub var
MsgBox var
End Sub
Private Sub Form_Load()
scrctrl.Language = "VBScript"
End Sub
Sub MySub(x)
x = 3
End Sub