Modify "Try....Catch.... End Try"

InertiaM

Well-known member
Joined
Nov 3, 2007
Messages
663
Location
Kent, UK
Programming Experience
10+
I have been using the Intellisense "Try...Catch...End Try" a lot recently, where I wished it also put in the Finally part.

Is it possible to modify the standard Intellisense snippets?
 
I'm using VB 2010 (and have VB 2008 still...), and they already have a Try-Catch-Finally snippet, short is "trycf"[tab]. Don't know about your VB 2005, but it is possible to add custom snippets also.
 
In 2005, trycf[tab] generates

VB.NET:
        Try

        Catch ex As ApplicationException

        Finally

        End Try

whilst try[enter] generates

VB.NET:
        Try

        Catch ex As Exception

        End Try

I think I'll be using trycf from now on :) Thanks John :)
 
try[enter] is not a snippet by the way, it is just automatic statement completion (check off Options>Text Editor>VB>'automatic insertion of end constructs' and you'll soon miss that :)).
 
I think I'll be using trycf from now on

If you need a Finally block then by all means do so but, since the addition of the Using statement, an exception handler with a Finally block is the exception rather than the rule. If I recall correctly, VB 2005 added the Using statement.
 
Back
Top