- Select Tools->Options->Editor->Require Variable Declaration to add an Option Explicit to all new modules. This forces you to declare all variables.
- Select Tools->Options->Editor->Auto Syntax Check to compile each line of code as you leave it.
- Use the Edit Toolbar Comment and UnComment commands to comment/uncomment blocks of code in a snap.
- If you right-click on the right-most pane of the Object Browser, you can issue the Show Hidden Members command. From this point on, the Object Browser shows all hidden properties and methods in any library, and you can use it to explore all object libraries in more detail.
- Visual Basic gives you the option to turn off error trapping in your projects. This is useful when you suspect that your error handlers contain errors themselves. To turn off error handling globally, choose Options from the Tools menu. Select the General tab, and select Break on All Errors. The next time you run your project in the development environment, Visual Basic will break whenever an errors in your code, whether the error is trapped or not.
- Add the following code to email error messages to helpdesk :
|
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Const SW_SHOWNORMAL As Long = 1
Public Const SYSTEM_ROOT As String = "C:\"
Private Sub SendErrorReport(ByVal istrErrorMessage As String)
' Replace CRLF with %0d token to give proper line breaks
istrErrorMessage = Replace(instrErrormessage, vbCrLf, "%0d")
ShellExecute Form1.hwnd, "open", "mailto:company.support@company.com" & _
"&subject=Application Error" & "?body=" & instrErrormessage, "", _
SYSTEM_ROOT, SW_SHOWNORMAL
End Sub
|