Here is a nice script to install the latest version of VirtualBox (4.0). This script is made by Nikolai Rachmaninoff from the Envied Ubuntu Group.The script adds the official Oracle VirtualBox repository before installing VirtualBox. You can use this script to install VirtualBox on Ubuntu 10.04 and 10.10.
To install VirtualBox 4.0 you first need to download the installer script from this page. When downloaded extract the content of the zipped file and double click on the Virtualbox 4.0 Installer.sh file. Select Run in Terminal then enter your password and the script will do the rest. The script will download an installer package and will place it on your desktop. When the installation is finished you can delete the file and find VirtualBox under Applications -> System Tools -> Oracle VM VirtualBox.