Ok so you need to research the following things please:
lookup the rand(); funtion for vb.net and convert your number to hex (Simplest way i can think of doing what you want)
Lookup SQL Querying (Going to be so much better than storing into a text file) (All you will need is to Add s/n's and then check if its used with a boolean flag)
With that you should be able to pull something off please reply with what you end up with