Vomiting blood is alarming and almost always due to serious illness.
If you vomit blood you should seek medical attention. If the amount of vomitus is large (estimated to be more than half a cup) or if you are experiencing giddiness, this is a life-threatening emergency. You should go to a hospital emergency department without delay.
Vomiting blood can be caused by the ulcer of the stomach or duodenum (the first part of the small intestine). It can also be caused by enlarged blood vessels in the esophagus or stomach (called varices). Cancer of the stomach or esophagus can sometimes cause vomiting of blood as well. Other causes of vomiting blood include esophagitis, tearing of the lower end of the esophagus and bleeding from abnormal blood vessels of the upper digestive tract.
The evaluation requires a gastroscopic examination, preferably done as soon as possible. As such, you should be kept fasted while seeking medical attention. Do not eat until instructed by your doctors.