Is it legal to download and use programs from the pirate's bay or
take the product codes for programs like visual studio you find online and use it for the program?
NO! It's not legal.
That said. The legality differs from country to country. Just look at where The Pirate Bay and Demonoid servers are. The people who usually find themselves in trouble are those who host or upload the content.
Now, legal or not in any country the software, music, etc. owner does state (in all EULA's I have ever seen) that re-distributing it is against the terms of the software. That's the entire program or just the license (serial key). Downloading from unauthorized sources is either prohibited or highly discouraged.
Keygens - One of the biggest forms of malware authors infecting users computers.
Just don't do it! I've tested many a keygen and 99.9% were infected. Same with unknown and fake codecs.
There are free alternatives to almost every type of software you can name. Sometimes better then the paid, bloated version. Also the paid versions usually have trials. If you like it, buy it so they can continue to develop and improve it.
Now. If you do plan on doing this. Don't discuss it here at Computer Hope. It's against
forum rules.