VCCodeElements.Find(String) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the specified code element of the parent object.
public:
System::Object ^ Find(System::String ^ bstrSearch);
public:
Platform::Object ^ Find(Platform::String ^ bstrSearch);
winrt::Windows::Foundation::IInspectable Find(std::wstring const & bstrSearch);
[System.Runtime.InteropServices.DispId(512)]
public object Find (string bstrSearch);
[<System.Runtime.InteropServices.DispId(512)>]
abstract member Find : string -> obj
Public Function Find (bstrSearch As String) As Object
Parameters
- bstrSearch
- String
Required. The name of the code element to search for. The string must be enclosed in double quotes.
Returns
A VCCodeReference object.
- Attributes
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
Remarks
If the specified code element was not found, the method returns null
.
See How to: Compile Example Code for Visual C++ Code Model Extensibility for information on how to compile and run this sample.