Check out the following which is in VB and you can use the logic and convert it in C++ http://www.go4expert.com/forums/showthread.php?t=23106