| Microsoft DirectX 8.1 (Visual Basic) | 
Clears the viewport, or a set of rectangles in the viewport, to a specified RGBA color, clears the depth buffer, and erases the stencil buffer.
object.Clear( _ 
    Count As Long, _ 
    ClearD3DRect As Any,
    Flags As CONST_D3DCLEARFLAGS, _ 
    Color As Long, _ 
    Z As Single, _ 
    Stencil As Long)
If the method fails, an error is raised and Err.Number can be set to D3DERR_INVALIDCALL.
For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.
This method fails if you specify the D3DCLEAR_ZBUFFER or D3DCLEAR_STENCIL flags when the render target does not have an attached depth buffer. Similarly, if you specify the D3DCLEAR_STENCIL flag when the depth-buffer format does not contain stencil buffer information, this method fails.
The following code fragment shows how to call the default case for Clear.
Dim Device As Direct3DDevice8 ' The following assumes that Flags, Color, Z, and Stencil ' have been set to valid values. Device.Clear 0, ByVal 0, Flags, Color, Z, Stencil
The following code fragment show how to call Clear when specifying an array of rectangles to clear.
Dim clearD3dRects(10) device.Clear 10, clearD3dRects(0), Flags, Color, Z, Stencil
Note that you pass in only the first element of the array of rectangles to clear.