Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AddMember Method (General Extensibility)
Cut
Run
Collapse the table of content
Expand the table of content

AddMember Method (General Extensibility)

Visual Studio .NET 2003

Creates a new member code construct and inserts the code in the correct location.

Note   This method is not supported for Visual Basic .NET.
[Visual Basic .NET]
Public Function AddMember( _
   Name As String, _
   Optional Value As Variant, _
   Optional Position As Variant _
) As CodeVariable
[Visual Basic 6]
Function AddMember( _
   Name As String, _
   Optional Value As Variant, _
   Optional Position As Variant _
) As CodeVariable
[C++]
HRESULT __stdcall AddMember(
   BSTR Name,
   VARIANT Value,
   VARIANT Position,
   /* [out, retval] */ CodeVariable** retVal
);
[C#]
CodeVariable AddMember(
   string Name,
   object Value,
   object Position
);
[JScript .NET]
public function AddMember(
   Name : String,
   Value : Object,
   Position : Object
) : CodeVariable

Parameters

Name
Required. The name of the new member.
Value
Optional. The .InitExpression of the CodeVariable object returned. It can be passed in either as a string or as an expression object.
Position
Optional. Default = 0. The code element after which to add the new element. If the value is a CodeElement, then the new element is added immediately after it.

If the value is Long, then AddMember indicates the element after which to add the new element.

Because collections begin their count at 1, passing 0 indicates that the new element should be placed at the beginning of the collection. A value of -1 means the element should be placed at the end.

Return Value

Returns a CodeVariable object.

Remarks

Adds a member to the enumeration and returns a CodeVariable object with IsConstant set to True.

When setting Value to a string, AddMember inserts any syntax required such as equal signs or semicolons if the variable does not already have an initialization expression. Depending on the languages and any syntactic or semantic checks it performs on the string passed in, setting this argument may fail. Languages are not required to check the string, and because the string is necessarily language-dependent, setting this argument could result in undefined behavior if the string has any ill-formed content.

When setting Value to a CodeElement, the decision as to whether the CodeElement must be newly-created depends upon the language implementation of the code model. Some languages may implement copying semantics if you pass in a code element that is already in a source file.

The correctness of the arguments is determined by the language behind the code model.

See Also

Applies To: CodeEnum Object | VCCodeEnum Object

Show:
© 2015 Microsoft