have a look at USBDemo, first post, first code, everything should be clear after that.
http://www.picbasic.co.uk/forum/showthread.php?t=5418