It's really easy when you have the correct instructions! Here's how I programmed my 2004 Audi A4 Quattro 1.8T Sedan:
1) Put the key in the ignition and turn to accessory mode (on, but don't start the engine)
2) Press and hold the outer buttons on the visor (should be I and III) until the red light begins FLASHING RAPIDLY (Can take up to 30 seconds, more or less). Next, press and hold the button you want to program until the light on the visor begins flashing slower than before. You now have 5 minutes to program it.
3) Using an opener that is already programmed, step outside the vehicle and press the button to program your car's visor. You'll need to be near the sensor/transmitter which is located in the driver's front quadrant (somewhere around the driver's headlight). Keep pressing the button until your hazard lights flash 3 (three) times.
4) Press the button located on your garage door opener motor (the box that actually opens and closes the garage door). Often, there is a light near this button which will begin flashing (For most, this will only stay in this learning mode for about 30 seconds).
5) Press and hold the button on your visor that you are programming for approximately 2-3 seconds. Repeat this until the garage door starts responding. Test it a few times and also make sure the opener that you used to program with still functions. Voila!
Note: Your key needs to remain in the ignition through the whole process. I don't know if the engine can be running or not, but I just programmed mine with the engine off and the key to accessory/on. Took me about 2 minutes total to get it working.
For more information, try Homelink's website. (http://www.homelink.com/program.php
Good luck and I hope this helps!