If you are currently within the United States, you neither need a visa nor can obtain one. That's because, in technical terms, a visa is simply a U.S. entry document. It is issued only by an overseas U.S. embassy or consulate, so as to allow someone to come to the United States, present it at the border or port of entry, and be admitted.
But few people understand this narrow meaning of the word "visa." So it's possible that there's a broader question being asked in wondering whether one can get a visa in the U.S., as to whether it's possible to go from having one type of visa status to getting a renewal or extension of one's immigration status, or to change status to another visa, or even adjust status to permanent resident (a green card holder) without leaving the United States.
A related question is whether someone can go from having no status in the United States to obtaining some legal right to be here, temporarily or permanently.
Whether you can renew or extend your status in the U.S. depends on the type of visa you received and entered the U.S. on.
Tourists with B-2 visas, for example, are allowed to ask U.S. Citizenship and Immigration Services (USCIS) for a renewal. (But it will be denied if USCIS thinks that what the person is really seeking is to live in the United States long-term.)
Many work visas can be renewed by USCIS at least once. People on F-1 student visas don't normally have to worry about renewals or extensions, unless they graduate or finish their course of study and plan to start a new school program, or need more time than was allotted on their original I-20 from the school. That's because students are admitted for "duration of status" (D/S), meaning for the amount of time it takes to complete their studies. (See How to Extend Your F-1 Student Visa.)
Check on the terms of your visa, or talk to an attorney for details. And note that you'll need to apply before your permitted stay runs out, and can be denied a renewal or extension if you have violated the terms of your original visa or committed a crime in the United States.
Whether you can change from your current immigration status to another one while in the U.S. depends on the type of visa you originally received.
For example, many students successfully switch to employment-based temporary visas. However, some visa categories don't allow changes of status to student. Most notably B-2 tourists can't change status to F-1, unless they were given a notation in their visa that they were coming to the U.S. as prospective students.
Other visa types that don't allow changes of status include fiancée (K-1), crew member (D), aliens in transit with or without a visa (C), exchange students subject to the two-year home residency requirement (J), alien witnesses and informants (S), and M-1 vocational students if they're trying to switch to F-1 student.
Also, people who entered the U.S using the Visa Waiver program (meaning they came from a country whose citizens aren't required to obtain a U.S. for short visits), won't be eligible to change status. In a few cases, however, Visa Waiver entrants can actually adjust status to permanent resident, namely if they're the immediate relative, such as the spouse, parent, or child, of a U.S. citizen and didn't use the visa waiver for the purpose of applying for a green card.
See Applying for an Extension of a U.S. Visa or Change of Status for more on these options.
If you have become eligible for permanent residence (a green card) while in the United States, and you are here on a valid visa, haven't stayed past the date you were supposed to leave, and haven't violated its terms (such as by working without authorization), you'll most likely be able to complete the application process within the United States. This is known as adjustment of status.
If your permitted stay has expired and you haven't left, however, you most likely can't apply to adjust status. Exceptions do exist, though, such as for immediate relatives of U.S. citizens (spouses, minor unmarried children, and parents of citizens who are over age 21).
If you are in the United States illegally after having entered the U.S. without inspection, perhaps by crossing the border at an unauthorized point, and you have become eligible for permanent residence (such as through marriage to a U.S. citizen), chances are you cannot apply to adjust status. This is subject to some narrow exceptions.
The immigration system is quite complex, and the exact options available to you will depend on your circumstances. Find an immigration attorney to discuss your options as soon as possible—before your permitted stay, if any, expires. The attorney might be able to point you toward possibilities you didn't know were available, or help you with the application process.