Microsoft KB Archive/819354

= BUG: You cannot use the Me keyword before the property name in a Visual Basic .NET structure =

Article ID: 819354

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-



SYMPTOMS
If you have a property defined in a Visual Basic .NET structure and you try to assign a value to that property in the same structure by qualifying the property name with the Me keyword, then you receive the following error:

Expression is a value and therefore cannot be the target of an assignment.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



WORKAROUND
To work around this problem, do not qualify the property name with Me when you assign a value to the property in the structure.



Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. On the File menu, click New, and then click Project. Under Project types, click Visual Basic Projects. Under Templates, click Console Application.

By default, Module1 is created.  In the Code window, replace the existing code with the following code: Option Strict On

Module Module1

Public Structure myStruc Private strName As String

Public Property myProp As String Get Return strName End Get Set(ByVal Value As String) strName = Value End Set End Property

Public Sub CallProperty Me.myProp = &quot;Hello&quot; End Sub End Structure

Sub Main

End Sub

End Module

End Module  On the Build menu, click Build Solution.

You receive the error message described in the &quot;Symptoms&quot; section of this article in the Task List.</li></ol>

<div class="references_section">