This documentation is archived and is not being maintained.

BodyText Property

Visual Studio .NET 2003

Gets or sets the body text of the parent object.

[Visual Basic .NET]
Public Property BodyText() As String
[Visual Basic 6]
Property Get BodyText() As String
Property Let BodyText( _
   ByVal NewValue As String _
HRESULT __stdcall get_BodyText(
   /* [out, retval] */ BSTR* retVal
HRESULT __stdcall put_BodyText(
   /* [in] */ BSTR NewValue
public string BodyText {get; set;}
[JScript .NET]
public function get BodyText() : String
public function set BodyText(
   NewValue : String


Body text is defined as the text between the declaration braces ( '{' and '}' ) of the code element represented by the parent object.


Imports EnvDTE
Imports System.Diagnostics
Imports VisualStudio.VCCodeModel

Public Module MyMacro

  'Adds a function to MyClass
    Sub AddFunctionCode()
        Dim cm As VCCodeModel
        cm = DTE.Solution.Item(1).CodeModel
        Dim cl As VCCodeClass
        cl = cm.Classes.Item("MyClass")
        Dim strBody As String
        strBody = "return 0;"
        Dim func1 As VCCodeFunction
        func1 = cl.AddFunction("MyFunction", vsCMFunction.vsCMFunctionFunction, "int")
        'Sets the property BodyText to strBody
        func1.BodyText = strBody
    End Sub

End Module

See Samples for Code Model Extensibility for information on how to compile and run this sample.

See Also

Applies To: VCCodeClass Object | VCCodeEnum Object | VCCodeFunction Object | VCCodeIDLCoClass Object | VCCodeIDLLibrary Object | VCCodeInterface Object | VCCodeMap Object | VCCodeNamespace Object | VCCodeStruct Object | VCCodeUnion Object