After googling, it looks like butterfly fish will probably be alright with your barbs. Evidently that is a common pairing.
If the tank is a standard 40g breeder, my guess would be 3-7 rams and 2-3 butterfly fish. Make sure you have some decor in case of bickering between the barbs and rams. It shouldn't get serious, but fin nipping happens.
Butterfly fish are more or less strictly surface dwellers, and will appreciate the footprint of a 40g breeder. They're really cool fish. Just make sure that your lid is tightly sealed with no openings they can fit through, because they can jump quite high, and will probably be convinced that there is a gigantic lake at the foot of the tank.
I would recommend you take your time stocking. Try a few of each and see what you like. Its always good to have room saved in the tank in case you find a fish that you absolutely must have. Your fish will appreciate an understocked tank as well.