A search of the CodeBank here should turn up several examples.

My own attempts can be seen in Clean Ping in VB6 Code, version 3 there being a little cleaner than version 2 posted there first.