Hi -
I've tried different ways to write to the variable me, but with no
luck. I've tried passing it to other methods as a byref parameter, and
even though it looks like it's written to the variable in the method,
when the method exits the variable is unchanged. Here is some code:
Module Module1
Sub Main()
Dim x As Integer = 3
Dim t As New test
Console.WriteLine(t.getS())
t.load()
Console.WriteLine(t.getS())
loadTest(t)
Console.WriteLine(t.getS())
Console.WriteLine("x = " & x)
intTest(x)
Console.WriteLine("x = " & x)
Console.ReadLine()
End Sub
Sub intTest(ByRef x As Integer)
x = 5
End Sub
Function getTest() As test
Dim t As New test("this one was made")
Return t
End Function
Function loadTest(ByRef t As test)
t = New test("load test succeeded.")
End Function
End Module
Class test
Private s As String
Sub New()
s = "not made"
End Sub
Sub New(ByVal s As String)
Me.s = s
End Sub
Sub New(ByVal t As test)
s = t.s
End Sub
Public ReadOnly Property getS() As String
Get
Return s
End Get
End Property
Public Sub load()
'Me = New test("")
load(Me)
End Sub
Private Sub load(ByRef t As test)
t = getTest()
't.s = "hi"
Console.WriteLine("in load")
End Sub
End Class
The external method (in the module) works fine, but the load doesn't
work in the class. I've tried making load a shared method, too, but
with no luck. Does anyone know of a workaround for this?
Thanks!
Terry