Add a New Method to the End of a Module

 < Free Open Study > 

Put Code Back into a Code Editor Window

The PutCodeBack method shown in the following code will replace a selected block of code in a module. It uses only the TextSelection object. You can find this code in the Utilities class in the code for Chapter 12.

   Public Sub PutCodeBack(ByVal s As String)     Dim selCodeBlock As TextSelection     'Dim datobj As New System.Windows.Forms.DataObject()     Try        selCodeBlock = CType(oVB.ActiveDocument.Selection(), _           EnvDTE.TextSelection)        'datobj.SetData(System.Windows.Forms.DataFormats.Text, s)        'System.Windows.Forms.Clipboard.SetDataObject(datobj)        'selCodeBlock.Paste()        selCodeBlock.Delete()        selCodeBlock.Insert(s, 1)     Catch e As System.Exception        MsgBox("Could not put code back in window.", _              MsgBoxStyle.Critical, _              "PutCodeBackInWindow")     End Try   End Sub

 < Free Open Study > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: