PC Review


Reply
Thread Tools Rate Thread

can't assign value to me?

 
 
Terry Heath
Guest
Posts: n/a
 
      10th Mar 2005
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

 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      11th Mar 2005
"Terry Heath" <(E-Mail Removed)> schrieb:
> I've tried different ways to write to the variable me, but with no
> luck.


You cannot assign anything to 'Me'. 'Me' will return a reference to the
containing object, so it doesn't make sense to change this reference at all.
What exactly do you want to archieve?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      11th Mar 2005
Terry,

"Me" is used in a class to tell that it is the ("top") object from the
class.
(And therefore unchangeable because than it would become a complete
different object).

As sample.
\\\
dim ColorBleu as ColorMeBlue
ColorBlue.ColorControls(me)
'assuming it is a class inheriting from control as by instance a dialogform
///
\\\
Friend Class ColorMeBleu
Private Sub ColorControls(byval this as Control)
For each ctr in this.Control
ctr.backcolor = color.blue
Next
End sub
end Class
///
I hope this helps?

Cor



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign a value of 1 for Yes Chuck W Microsoft Access 10 15th Feb 2010 04:04 PM
Assign a hot key jadent Microsoft Outlook 1 9th Feb 2010 11:10 AM
Can't assign a value ... Sue Compelling Microsoft Access Form Coding 5 4th Mar 2009 07:57 AM
Cannot assign a Value =?Utf-8?B?U3ByaW5rcw==?= Microsoft Access Forms 3 13th Oct 2006 06:35 PM
Assign Task problem-Can't accept or assign =?Utf-8?B?RE9M?= Microsoft Outlook Calendar 5 29th Jun 2006 06:57 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:35 PM.