The longest journey I made was from Saigon to Hué (18 hours in the train), and even if the ride was ok, I would not recommend to take it for longer than I did, but I would do it again without any hesitation. Travelling across Vietnam, I used both sleeper bus and trains, and I really prefer the latter. Sure, beds on trains are a little hard, but a train is not a five-star hotel. Sure toilets are a little smelly and have no toilet paper (as most places in Vietnam), but toilets in trains in general are not the most welcoming, including the wealthiest contries in the world as Switzerland, so I found them pretty ok, and they are always here, not as on the road with the bus. Sure the train is noisy, peolple are talking, the train on tracks is making noise, but I prefer it to the blarring horn of bus and trucks around you on the road. Plus, in trains, you are four by compartments, not 40 as in sleeper bus.
Finally, the train is a safer way to travel (chances of an accident are close to zero), it is inexpensive, and it is a great way of meeting local people. To sum it up, I would say that if you are travelling between two five-stars resort in Vietnam and want the greatest comfort, take a flight. If you want an inexpensive travel and see the real Vietnam, take the train, you won't regret it. (PS : I took three different trains on my journey across the country, and it is true that some are more modern and better equiped than others, but you can't tell in advance...)