473,323 Members | 1,570 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,323 software developers and data experts.

cannot set property value in a structure using Me

Does any one know why the following code works the way? and in C# it works in a different way what is the meaning of "Me" in VB.NET and why is it different than in C#

Structure Test
Private mName As String

Property Name() As String
Get
Return Me.mName
End Get
Set(ByVal Value As String)
Me.mName = Value
End Set
End Property

Sub foo(ByVal s As String)
Me.Name = s 'this line fails
Name = s 'this line does not fail
End Sub

End Structure

C# code
struct Test
{
string mName;

public string Name
{
get
{
return this.mName;
}
set
{
this.mName = value;
}
}

public void foo(string s)
{
this.Name = s; //no error
}
}

Nov 21 '05 #1
4 3924
I don't know why it doesn't work using Me that way. But I found that this seems to work.

Public Sub foo(ByVal s As String)
Dim r As String
r = (Me.Name = s).ToString
Name = s 'this line does not fail
End Sub

"Sankar Nemani" <sn*****@nospamlumedx.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Does any one know why the following code works the way? and in C# it works in a different way what is the meaning of "Me" in VB.NET and why is it different than in C#

Structure Test
Private mName As String

Property Name() As String
Get
Return Me.mName
End Get
Set(ByVal Value As String)
Me.mName = Value
End Set
End Property

Sub foo(ByVal s As String)
Me.Name = s 'this line fails
Name = s 'this line does not fail
End Sub

End Structure

C# code
struct Test
{
string mName;

public string Name
{
get
{
return this.mName;
}
set
{
this.mName = value;
}
}

public void foo(string s)
{
this.Name = s; //no error
}
}

Nov 21 '05 #2
Hi Sankar,

This is a known issue and the product group is planning to fix the problem
in the next version of .net framework but I can not guarantee if that will
be done.
Here is a KB, you may take a look.
BUG: You Cannot Use the Me Keyword Before the Property Name in a Microsoft
Visual Basic .NET Structure (819354)
http://support.microsoft.com/default...B;EN-US;819354

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
That helps.
Thanks
Sankar
""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:vN**************@cpmsftngxa06.phx.gbl...
Hi Sankar,

This is a known issue and the product group is planning to fix the problem
in the next version of .net framework but I can not guarantee if that will
be done.
Here is a KB, you may take a look.
BUG: You Cannot Use the Me Keyword Before the Property Name in a Microsoft
Visual Basic .NET Structure (819354)
http://support.microsoft.com/default...B;EN-US;819354

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4
Hi Sankar,

You are welcome, I am glad my reply is of help.
Cheers!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #5

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

Similar topics

6
by: Cc | last post by:
hi, is there a way to use byref on property set , because i would like to pass the value into the variable byref ?
5
by: Dan Iregren | last post by:
Hi, I need to know when a property has ben modified (IsDirty). The most obvious way to solve the problem is perhaps something like the following; Private m_sFirstName As String Private...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
62
by: djake | last post by:
Someone can explain me why to use property get and property set to access a value in a class, insted of access the value directly? What's the usefulness of property statements in VB.NET? Thanks
6
by: D Witherspoon | last post by:
I have a Structure I have created and am using it as a Public Property of a class. Here is the property. ------------------------------------------------------ Dim _MyID As SInteger Public...
5
by: Sam | last post by:
Hi All I have couple of question regarding property of a class and structures. **** ---- Here is my class and structure ---- ***** 1. Public Structure MyPoint 2. Dim p As Point 3. ...
6
by: JSheble | last post by:
Are there any reasons why I shouldn't or couldn't use a structure as a property in a class? Specifically since structures are value types and objects are reference types? I have a Shipping...
45
by: Zytan | last post by:
This returns the following error: "Cannot modify the return value of 'System.Collections.Generic.List<MyStruct>.this' because it is not a variable" and I have no idea why! Do lists return copies...
6
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
Yesterday Visual Studio gave me a strange error both at compiletime and at designtime that had no obvious connection to anything I had changed recently. After some effort tracking down the problem...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.