From another thread:
I actually just had this happen to one of my silver dollars. He had it very bad unfortunately, and it progressed from swimming to stay in his position to not being able to do so, and floating to the top (and laying like a pancake on the top of the water). I took him out and put him in the hospital tank. I was worried about his gills getting oxygen burn from being exposed, so I put a heavy plastic 'hang on back' breeder-type thing I had from a long time ago over him and put a log on top - he would float at the top of it, but didn't hit the top of the water.
I believe it was either fish bloat or swim bladder disorder related to diet - too much protein and he got all stopped up. This affected his swim bladder. One of my other silver dollars was barely showing signs of this as well, swimming to stay in place, so I have fasted them all week and given a few peas here and there.
In the hospital tank I added epsom salts on Monday, a tblsp per 5 gallons, and last night I added a powder I got at the LFS - it's abbreviation was TMT but I can't tell you what it is without looking at the package. It was recommended to help swim bladder disorder. He was doing better this morning (this all started Sunday) and was swimming to stay in position instead of pancaking himself at the top. I'm going to put him in the main tank today as I'm gone for the long weekend and I'm sure he'll be fine.
I was super happy to fix this problem because he's a very healthy fish and I was upset that it happened to him. Hopefully your barb won't have this happen again!