Compartilhar via


Imports.Remove Method

Removes an imports statement from the Imports collection. The imports statement to be removed may be indexed by either the string specifying the import or by a one-based index.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)

Syntax

'Declaration
Sub Remove ( _
    index As Object _
)
void Remove(
    Object index
)
void Remove(
    [InAttribute] Object^ index
)
abstract Remove : 
        index:Object -> unit
function Remove(
    index : Object
)

Parameters

  • index
    Type: Object

    Required. Either a one-based index into the collection, or the imports statement string to remove.

Remarks

An error is generated if the imports statement does not exist in the collection. If you use a string index, the string must be an exact match for the imports statement. For example, an index of "SomeNamespace" will not remove the imports statement "SomeNamespace.*".

Examples

' Macro Editor
Imports VSLangProj
Public Sub RemoveImport()
   ' Project must be a Visual Basic project.
   Try
      Dim vsproject As VSProject = _
         CType(DTE.Solution.Projects.Item(1).Object, VSProject)
      vsproject.Imports.Remove("SomeAlias = SomeNamespace.*")
      vsproject.Imports.Remove(1)
   Catch e As System.Exception
      MsgBox(e.Message)
   End Try
End Sub

.NET Framework Security

See Also

Reference

Imports Interface

VSLangProj Namespace