One thing you can do is to go to a drug rehab and go through detox. In that case you will be medically supervised during your withdrawal from the drug and medical staff will likely give you medication that will help you through the uncomfortable withdrawal symptoms. This is the ideal solution for most people who are addicted to opiates but keep in mind that it is quite expensive in most cases. If you have insurance then you might be able to go to treatment without paying much, but if not then you will probably have to pay cash and the costs will be similar to a stay in a hospital.
Another option you will have if you get addicted to prescription medications is to work with your doctor on a solution. In some cases a doctor can prescribe different medications that can be used to treat your opiate dependence and possibly also give you medicine to treat any pain issues that you might be having.
There is another option for opiate addiction known as ultra rapid detox but this is fairly expensive and is not covered by insurance companies. If you choose to go this route you will need to research it heavily so that you clearly understand the costs and the risks involved.
Learn more about hydrocodone addiction and vicodin addiction.