Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns the specified code element of the parent object.
Namespace: Microsoft.VisualStudio.VCCodeModel
Assembly: Microsoft.VisualStudio.VCCodeModel (in Microsoft.VisualStudio.VCCodeModel.dll)
Syntax
'Declaration
Function Find ( _
bstrSearch As String _
) As Object
Object Find(
string bstrSearch
)
Object^ Find(
String^ bstrSearch
)
abstract Find :
bstrSearch:string -> Object
function Find(
bstrSearch : String
) : Object
Parameters
- bstrSearch
Type: System.String
Required. The name of the code element to search for. The string must be enclosed in double quotes.
Return Value
Type: System.Object
A VCCodeReference object.
Remarks
If the specified code element was not found, the method returns nulla null reference (Nothing in Visual Basic).
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information on how to compile and run this sample.
Examples
This example looks for the THIS_FILE variable in the 'stdafx.h' file. If the variable is not found, it is added.
' Macro code.
Sub AddThisFile()
Try
Dim vcCM As VCFileCodeModel
Dim vcCodeElements As VCCodeElements
vcCM = CType(DTE.Solution.Item(1). _
ProjectItems.Item("stdafx.h"), VCFileCodeModel)
vcCodeElements = vcCM.CodeElements
If (vcCodeElements.Find("THIS_FILE") Is Nothing) Then
Dim codeVariable As VCCodeVariable
codeVariable = vcCM.AddVariable("THIS_FILE", "char")
End If
catch e as System.Exception
MsgBox(e.Message + e.StackTrace)
End Try
End Sub
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.