Hello, my name is***** and I have over 20 years of experience as a veterinarian. I am sorry to hear that Barney has had a relatively poor appetite and is vomiting. I understand your concern because this has lingered.
Ideally because this has lingered and he's a bit older he should see his veterinarian and some diagnostic testing should be done.
Vomiting and a lack of appetite can be related to chronic pancreatitis, a dietary allergy or sensitivity, toxin exposure, a viral or bacterial infection, a gastrointestinal foreign body (string, rubber bands), inflammatory bowel disease, or heartworm disease. Other causes include hyperthyroidism (a tumor of the thyroid gland), internal organ failure, or an abdominal mass.
I understand that you may not leave anything out purposely but cats that are playful could find and ingest something without your knowledge which could lead to a full or partial gastrointestinal obstruction.
Most of the time with simple stomach upset they can start to feel better in 24-48 hours, for example from an infection or eating a bad treat or bug.
But it sounds like this has lingered. Is he losing weight too? If he continues vomiting then he should be checked and some testing should be done.
In the meantime at home to try and settle his stomach and get him eating you can give either:
1) Pepcid ac (famotidine) at a dose of ¼ of a 10mg tablet per 5 to 10 pounds of body weight every 12 hours
2) Prilosec (omeprazole) at a dose of ¼ of a 10mg tablet per 5 to 10 pounds of body weight every 24 hours
These are acid reducers and should help him feel better. They are quite safe and can be used for several days if necessary.
A couple of hours after giving the acid reducer I recommend offering soft foods mixed with water to make eating and swallowing more comfortable.
Or you can try offering meat baby foods or a bland diet of 2/3 boiled minced white skinless chicken and 1/3 boiled white rice mixed with some low salt chicken broth to make it more palatable, easy to lap up and swallow, and get additional fluids into him.
If Barney continues to not eat well and continues to vomit he should see his veterinarian or an emergency veterinarian for an examination, diagnostics and intravenous fluids and supportive care.
Please let me know if you have any further questions.