First question: "PPM 40" of WHAT? That's like saying I have 40 pounds... pounds of what? Nitrate? TDS? Something else?

Do you know more specifically what the ammonia level was? Remember, an ammonia/ammonium (TAN or total ammoniacal nitrogen) reading of 1 PPM can mean death or survival of your fish at different pH levels. Anything above 7 pH starts dramatically increasing the problems. For instance, a reading of 1 PPM is 1000% more toxic at 7.1 pH when compared to 6.1 pH. However, I agree with you that the goldfish "should" tolerate those levels at that pH...

I wouldn't be so quick to rule out disease. Maybe your fish were so unhealthy, as you implied, before you bought them that they simply succumbed to an existing condition. I was always happy to let the ones that die off at the start go to fishy heaven because Mother Nature was selecting the strongest ones for me. It has been over a year and my PetSmart feeder goldies are HUGE and quite alive. However, I almost always end up buying fish from there that come with (free bonus with every fishy purchase) ick or some other parasite or disease... you have to just observe and diagnose and fix it.

What about chlorine? You didn't mention how fast they died after you got them. Goldfish don't seem to tolerate chlorine from my tap very well, but the Tilapia don't care 1 bit (obviously because of a difference in physiology, but I won't get into it).

It could also be stress. Were you constantly scaring them with your face? JUST KIDDING, but seriously they can die from stress. This usually involve other creatures living in the tank, but it can also be from handling them too much (or even once in some specific cases). I just handled about 50 Tilapia and I smell pretty fishy writing this post... anyway, I had a few goldfish with the Tilapia. I freaked out because I thought I spotted ick on a white goldfish about 8 inches long. Once I got her, I noticed it was scale damage probably from the Tilapia. I noticed the Tilapia are catching up in size to the large goldfish (which was the only reason I felt the larger goldfish were safe with the Tilapia) and not to mention I'm seeing the caudal fins turning red on the Tilapia, meaning they are likely being more aggressive now. That fish should be okay (I hope), but it seemed a bit weak because it was so easy to catch. The escape behavior was minimal. She could die from stress, as your fish may have... may have not...

ANYWAY, hope that helps. It's impossible to diagnose based on nothing! If this was a math question I would circle "not enough information", but even with a lot more information it would likely be impossible to say without a histological autopsy on the dead fish. Cheap microscopes are cheap. Get a few fish books. You'll be a pro in no time.

"You're not a real fish farmer until you've killed a million fish." --someone wise