Visual Basic Code of the Week (COTW)
Issue #74
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.


There are several new articles available at

Download a free copy of NetMon - Your Internet Performance Monitor at

Special Deal for this week only

Subscribe to Code of the Week for only $14.95 (regularly $19.95). Just jump to our SECRET order page at

In this Issue

In this issue we are introducing a class module that shows an easy way to handle the hourglass mouse cursor (or any other cursor).

This source code is designed for VB 5.0 and up. Similar methods can be used in VB 4.x. Questions? Email us at


The cMouseCursor class provides an easy method for displaying the Hourglass cursor during time-consuming tasks. You simply declare the object and call StartTask.

If you have any questions about using or creating this control, let us know at


Public Sub StartTask(Optional MouseCursor As MousePointerConstants = vbHourglass)

This subroutine will show the mouse cursor you specify as a parameter or the default of vbHourglass.

Public Sub StopTask()

StopTask is the nice way to make the original mouse cursor reappear after completing your time-consuming task. If you declare the cMouseCursor object within a local subroutine then you skip calling this because the Terminate event of the class will automatically do so for you. It is good programming practice to call this method.


No return values in this class.

Sample Usage

The below sample describes how to use the cMouseCursor class.

    Dim mc As New cMouseCursor

    ' vbHourglass is the default so it is optional.  We specified it here
    ' to show how you would do this.  See the source for all the available
    ' options.
    mc.StartTask vbHourglass
    '  Do some time consuming task here.

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945