在VB.NET(或C#)中,如何在程序中确定类helper.vb中的公共变量是否在项目中的任何位置使用?
解决方法
从
MSDN起
Find对象允许您搜索和替换支持此类操作的环境中的文本,例如代码编辑器.
它主要用于宏观录制目的.编辑器的宏记录机制使用Find而不是TextSelection.FindPattern,以便您可以发现全局查找功能,并且因为它通常比将TextSelection对象用于诸如Find-in-files之类的操作更有用.
如果搜索操作是异步的,例如“全部查找”,则在操作完成时会发生FindDone事件.
Sub ActionExample() Dim objFind As Find = objTextDoc.DTE.Find ' Set the find options. objFind.Action = vsFindAction.vsFindActionFindAll objFind.Backwards = False objFind.FilesOfType = "*.vb" objFind.FindWhat = "<Variable>" objFind.KeepModifiedDocumentsOpen = False objFind.MatchCase = True objFind.MatchInHiddenText = True objFind.MatchWholeWord = True objFind.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral objFind.ResultsLocation = vsFindResultsLocation.vsFindResultsNone objFind.SearchPath = "c:\<Your>\<Project>\<Path>" objFind.SearchSubfolders = False objFind.Target = vsFindTarget.vsFindTargetCurrentDocument ' Perform the Find operation. objFind.Execute() End Sub <System.ContextStaticAttribute()> _ Public WithEvents FindEvents As EnvDTE.FindEvents Public Sub FindEvents_FindDone(ByVal Result As EnvDTE.vsFindResult,_ ByVal Cancelled As Boolean) _ Handles FindEvents.FindDone Select Case Result case vsFindResultFound 'Found! case else 'Not Found Ens select End Sub