You can create a Visual Web Part for SharePoint 2013 Online.
Your web part will be contained in a Sandbox Solution which you will develop locally. Once development is complete you will upload the Solution Package created by Visual Studio to SharePoint Online. Once this is done your web part will be available for use.
As mentioned, development will be done locally so you will need a machine that has both SharePoint 2013 (Foundation or Server) and Visual Studio 2012 or 2013.
Here are the steps build and deploy the web part:
- Create a new project based on the "SharePoint 2013 - Empty Project" template
- In the SharePoint Customization Wizard enter the URL of the local SharePoint site you will use for testing during development and choose to "Deploy as a sandboxed solution" (you cannot deploy farm solutions to SharePoint Online)
- Add a new Visual Web Part to the project
- Develop and test the web part locally until it has the desired functionality
- Publish your solution to the SharePoint Online site using the remote publishing feature of Visual Studio (see How to: Deploy, Publish, and Upgrade SharePoint Solutions on a Remote Server)
- Go to you SharePoint Online site and test your web part
One important note: sandbox solutions that contain managed (i.e. VB or C#) code are considered to be deprecated and they may not be supported in future versions of SharePoint. Looking forward, the replacement for web parts contained in sandbox solutions would be App parts that are implemented using the new Cloud App Model.