Retrieve a Whole Procedure from a Code Editor Window

 < Free Open Study > 

Get Code from a Code Editor Window

The following code shows the GetCodeFromWindow method of the Utilities class. It uses only the TextSelection object. It assumes that the user has selected a block of text on which to perform some functionality.

 Public Function GetCodeFromWindow() As String   Dim s As String   Dim selCodeBlock As TextSelection   Dim oUtil As New Utilities(oVB)   Try      selCodeBlock = _        CType(oVB.ActiveDocument.Selection(), _        EnvDTE.TextSelection)      GetCodeFromWindow = selCodeBlock.Text   Catch e As System.Exception      MsgBox("Error: " & e.Message, MsgBoxStyle.Critical, _        "GetCodeFromWindow")   End Try   oUtil = Nothing End Function

 < 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: