Visual Basic

NB. Although you can still download and install these examples in Windows 7, a lot of the project files were created in Visual Basic 5. These could be adapted to Visual Basic 6, but and later versions are sufficiently different as to be incompatible. I am currently in the process of updating the examples to Visual Studio 2010 - if the example you want has yet to be converted, then please come back later in the year.

I can't hope to provide and full and detailed Visual BASIC tutorial here - there are plenty to good books about and I can't be bothered to write another one. I will thereford introduce the basic concepts and give some examples of some of the sorts of things that are possible (including the source). If you're interested, you can then go and buy a book!

There is also some VBScript (the script version of Visual BASIC for use on web pages) on the Lottery page in the JavaScript section. There is also an example of VBScript on the Iteration and Recursion page in the Programming section.


BASIC (Beginners All-Purpose Symbolic Instruction Code) is a simple and fairly easy-to-learn programming language. Anyone who had "computer" lessons, or used a computer at any time during the 80s is almost certain to be familiar with it. Early versions of DOS, and early home computers such as the Commodore VIC20 & 64, Sinclair ZX-80/1 and Spectrum, and all Acorn machines came with versions of BASIC. It was frowned upon in the early days because it allowed "poor" programming techniques, such as the GOTO command, and many simpler versions didn't support the use of functions or recursion.

It evolved into a fully-fledged procedural programming language used by professionals, and by the late 80s, many commercial applications for DOS were written in BASIC. The early home computers came with BASIC interpreters (i.e. the program was converted into machine code as it ran) and were therefore slower. BASIC compilers then appeared - compiling (i.e. doing all the translation before the program is executed) sped up the program, and also meant that other people couldn't view (and therefore steal) your code.

Objects, etc.

Then came Windows. This led to people having to change the way they thought about writing programs. In DOS, you could only run one application at a time, and you could only view one screen of your application at a time. This meant that the execution of your code could start at top and just run through, showing the screens in the right order, until you reached the end.

You can run several Windows applications at the same time, and you can have several screens from your application open at the same time. This means that things can often be done in any order, and your program doesn't necessarily run from top to bottom.

The Visual variant is essentially the same as traditional BASIC, except that there is a design environment that lets you draw your screens (or forms), and fragments of codes are attached to objects and events, rather than you having to write a whole program that runs from top to bottom. For example, to add a button to a form that would close the form, you select the OnClick event for the button object, and enter the code form.hide.

Newer versions of Visual Basic, from .Net onwards, give the programmer access to a lot more functions, but also remove some features, such as control arrays. For that reason, you might notice that the newer projects have been programmed differently in some cases. The Colour Mixer, for example, takes advantage of new string formatting functions to convert values to hexadecimal, rather than doing it mathematically.

Active X

As well as creating standalone applications, you can also use Visual BASIC to create ActiveX controls. These are small programs or sections of programs that you can use elsewhere, either in another application written in any programming language, or on a web-page (provided that you're using Internet Explorer). Click here for an example (note that you may get a security warning - this is nothing to worry about; my control is quite safe!)

Installing the Applications

The following pages show screen shots of small applications that I've written in Visual BASIC (version 5). You are free to download and use them as long as you do not redistribute them for profit. The applications are unsupported, and you download them at your own risk. No liability is accepted for problems caused by installing these programs. And obviously, they're not really finished, either.

Decompress (i.e. un-zip) the downloaded file into the a folder (or "directory"), and run (double-click) the one called setup.exe. This should start the installation program, which will ask into which folder you want to install the programs, etc. All files have been checked for viruses using the latest version of my current virus scanner.

If you want to install any of the newer VB 2010 examples, then you can do that directly from the links on the page. You will get a security warning because I haven't been verified as a publisher, but if you're concerned then you can download setup.exe and run your anti-virus software on it before running it.