Objects

Debug Object

Syntax:

Debug.Clear

-or-

Debug.Print [expr[;...][;]]

Group: Miscellaneous

Description: Form 1: Clear the Output tab.

Form 2: Print the expr(s) to the Output tab. Use ; to separate expressions. A num is it automatically converted to a string before printing (just like Str$( )). If the instruction does not end with a ; then a newline is printed at the end.

Example:

Sub Main
X = 4
Debug.Print "X/2=";X/2 ' 2
Debug.Print "Start"; ' don't print a newline
Debug.Print "Finish" ' print a newline
End Sub

Err Object

Syntax:

Err

Group: Error Handling

Description:
Set Err to zero to clear the last error event. Err in an expression returns the last error code. Add vbObjectError to your error number in ActiveX Automation objects. Use Err.Raise or Error to trigger an error event.

Err[.Number]

This is the error code for the last error event. Set it to zero (or use Err.Clear) to clear the last error condition. Use Error or Err.Raise to trigger an error event. This is the default property.

Err.Description

This string is the description of the last error event.

Err.Source

This string is the error source file name of the last error event.

Err.HelpFile

This string is the help file name of the last error event.

Err.HelpContext

This number is the help context id of the last error event.

Err.Clear

Clear the last error event.

Err.Raise [Number:=]errorcode [, [Source:=]source] [, [Description:=]errordesc] [, [HelpFile:=]helpfile] [, [HelpContext:=]context]

Raise an error event.

Err.LastDLLError

For 32 bit windows this returns the error code for the last DLL call (see Declare). For 16 bit windows this always returns 0.

Example:

Sub Main
On Error GoTo Problem
Err = 1 ' set to error #1 (handler not triggered)
Exit Sub

Problem: ' error handler
Error Err ' halt macro with message
End Sub

Me Object

Syntax:

Me

Group: Object

Description: Me references the current macro/module. It can be used like any other object variable, except that its reference can't be changed.

Example:

Sub Main
DoIt
Me.DoIt ' calls the same sub
End Sub

Sub DoIt
MsgBox "Hello"
End Sub