Weight gain from medications?
You haven't given enough info to answer your question. What were you on and why were you on it? Are you on anything currently? Losing weight from illness in the past says nothing about your current weight issue. Your problem sounds more involved than simple weight gain from excess calories.
You need to eat better and not less. Increase the portions of vegetables a lot - decrease the meat -- avoid the highly processed foods - the less than whole grains. Eating better is the key - not eating fewer.