Your sound bar can be connected to the UA40C500QF. Get an appropriate audio cable based on the sound bar. You'll either need a optical digital audio cable or an analog audio cable with a 3.5 mm plug on at least one side. (If your sound bar has an AUX input, then a 3.5 mm to 3.5 mm M/M audio cable is appropriate. Otherwise, you may need an RCA (M/M) to 3.5 mm audio cable or some sort of RCA to 3.5 mm adapter (F on one side, M on the other).) Connect this cable to the audio out on the TV (headphone or digital audio) and the appropriate audio in on the sound bar.
Set the sound bar source to the chosen input (Aux or Digital In (D.In on some systems). Next, set the TV to use External speakers. This is in the Audio sub-menu. The volume will now be controlled by the sound bar volume control.
You can still use the HDMI cable (HDMI out to any HDMI in on the TV) if you want to use the TV screen when changing the settings on the sound bar. Just change the TV source to that HDMI port with the Source button on the TV remote or on the TV (the left-most button on the front panel). Then change your source back to the video signal for the TV to view items connected to the other HDMI ports. If your sound bar has an HDMI input, you would similarly use set the TV to the sound input to watch that source.
I hope this helps. See the manual for the UA40C500Q for the details on setting the speakers to External speakers. The manual is available on the support page: https://www.samsung.com/au/support/model/UA40C5000QFXXY/
. The current link to the manual is http://downloadcenter.samsung.com/content/UM/201003/20100316163048500/BN68-02727A-00Eng-0225.pdf