Customize function/sub template

Access100

New member
Local time
Today, 04:05
Joined
Feb 12, 2010
Messages
1
In vba, whenever we create a new function/sub, VBA will only create a 2 line template, is there a way to customize the behavior, so that a much more useful template is showing up. like:

Private Function FunctionName() As String
' Purpose:
' Arguments:
' Example:
' Returns:
Const cstrProc As String = "FunctionName"
On Error GoTo FunctionName_Err

'''''''''''''''''
FunctionName =
FunctionName_Exit:
Exit Function
FunctionName_Err:
Call lci_ErrMsgStd(mcstrMod & "." & cstrProc, Err.Number, Err.DESCRIPTION, True)
Resume FunctionName_Exit
End Function
 
Why not create your own template and copy/paste it when needed?

Why have Const cstrProc As String = "FunctionName" when it’s only used in one place?

Why pass Err.Number and Err.DESCRIPTION since they are global variables?

Why use FunctionName in On Error GoTo FunctionName_Err?

Why be in such a hurry to write VBA?
 

Users who are viewing this thread

Back
Top Bottom