| < Free Open Study > |
|
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 > |
|