473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

can't assign value to me?

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

Nov 21 '05 #1
2 2310
"Terry Heath" <th****@gmail.com> 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/>

Nov 21 '05 #2
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

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: news.tdl.com | last post by:
Im passing values between SELECT boxs. Once submitted I want to pass the value to the opening page. It works ok but I only get a single value (last one) , I need them all. How can I do this.????...
4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
2
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
0
by: Tim::.. | last post by:
HELP... Can someone please tell me why I keep getting the following error! I am new to AD is ASP.NET and would really appritiate any advice! Thanks ...ERROR.. Exception Details:...
5
by: Just Me | last post by:
Given a button name Btn_5 and Index=5 I want to do something like dim zz as string = Btn_??Index??.Text or given an array of buttons, do:
6
by: Bill foust | last post by:
I'm running into a situation there I think an operator overload would solve the issue, but I'm unable to make it work for some reason. If anyone can help here I would appreciate it. I have a...
1
by: harpreet1433 | last post by:
how to assign value to a hidden field of stuts form what i actually want to do that assign it through javascript document.all.fieldname=value works well under IE and Netscape but in...
12
by: Danny Colligan | last post by:
In the following code snippet, I attempt to assign 10 to every index in the list a and fail because when I try to assign number to 10, number is a deep copy of the ith index (is this statement...
28
by: Stef Mientki | last post by:
hello, I'm trying to build a simple functional simulator for JAL (a Pascal-like language for PICs). My first action is to translate the JAL code into Python code. The reason for this approach is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.