Passing an object reference by reference where the object has a default property 
Author Message
 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



Sun, 16 Feb 2003 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Referencing object in form in code / Subform reference problem in code

2. reference to a non-shared member requires an object reference

3. dotnet Reference to non-shared member requires object reference - Global.asax.vb

4. Reference to a non-shared member requires an object reference

5. Reference to a non-shared member requires an object reference

6. HELP: Recordset Type mismatch for object reference passing

7. Passing Object reference to a child form

8. Passing references to ActiveX Exe object

9. Passing references to other objects!

10. Problem in passing the object reference

11. passing a connection object reference over DCOM

12. Pass connection by reference to another object

 

 
Powered by phpBB® Forum Software