^~(:Wh@'.+)~(:Wh@/#).+
Select Edit -> Find & Replace -> Find in files… or just press CTRL+SHIFT+F
Check Use and select Regular expressions.
Type the following as the text to find:
for C#
^~(:Wh@//.+)~(:Wh@\{:Wh@)~(:Wh@\}:Wh@)~(:Wh@/#).+.
for VB.NET
^~(:Wh@'.+)~(:Wh@/#).+.
Select where you want to do the search/count: file, project or solution.
If you select Current project or Entire solution, you also need to specify the file types that will be included in the search.
Proceed with the “search” and at the bottom of the Find results window you will see the total line count.
The regular expression that is used match every line that are not a comment (//), a compiler directive (starts with #), a single opening or closing brace, or blank lines.