Udemy logo

visualbasictutorialVisual Basic is one of the most beginner friendly programming languages around. Originally meant to be an easy to use, graphical implementation of the once popular BASIC (Beginner’s All-Purpose Symbolic Instruction Code) language, Visual Basic has developed a rabid fan base over the years. It is especially suitable for beginners and entrepreneurs trying to break into the programming business.

What is Visual Basic?

Visual Basic 6.0 is both a programming language and an Integrated Development Environment (IDE). This means that instead of writing thousands of lines of code, you can create complicated programs by stringing together different forms and components. The end result is a refreshingly simple, fun and easy to use approach to programming that’s great for beginners as well as advanced coders.

Originally tooled from BASIC (which, incidentally, was the first software program Microsoft worked on – when the company was still called ‘Micro-Soft’), Visual Basic was first launched in 1991. Version 6.0 saw a final release in 1998. The software continued to receive minor upgrades in the next decade, though Microsoft officially stopped supporting it in 2008 in favor of Visual Basic .NET (VB.Net).

Visual Basic follows the COM (Component Object Model) programming model Microsoft first released in 1993. The COM model emphasises flexibility by creating objects that can work across different environments and machine boundaries. This helps in rapid application development (RAD) of applications that require a rich GUI.

Because Visual Basic is so, well, visual, it is ideal for beginners. You can jump right in and create simple programs without any prior programming experience. At the same time, the language is powerful enough for complicated, professional applications.

Learning Visual Basic offers another benefit – it is the basis of VBScript, a scripting language that is used in all ASP (Active Server Pages) applications.

Visual Basic also finds a lot of use in Excel. Learn how to harness the true power of Excel with this Visual Basic for Microsoft Excel tutorial.

Understanding How Visual Basic Works

Visual Basic is essentially a Windows programming language. Because VB is so deeply integrated within Windows, you need to understand how this operating system works before you can start creating your own programs.

Windows, Messages and Events: The Three Pillars of Microsoft Windows

Windows is easily one of the most complicated software programs around. But beneath the surface, Windows, regardless of the OS version, works on the interaction between three basic components: windows, events and messages.

Windows: Any rectangular box that displays information or runs an application is called a window. The browser that you’re reading this in? That’s a window. The folder that pops up when you fire up Windows Explorer? That’s a window as well. So is the dialog box reminding you to change your firewall settings, rename a folder, or download a file. Basically, any user-facing GUI element can be called a window. Each window is identified by the operating system with a unique hWnd number.

Events: Any sort of input or action within Windows is called an ‘event’. Clicking an icon, pressing a key, moving a window around – these are all examples of events. An event basically creates a message telling Windows to perform some action.

Messages: Every time an event occurs, Windows creates a message which is then directed to the appropriate application to perform an action. Think of messages as the mediators between events and applications.

Consider an example: you know you can close a program/window in Windows by clicking on the red ‘X’ button in the top right corner. Clicking on this button is an event, which sends a message to Windows to close the program window.

Streamline your workflow and increase productivity by learning how to use VBA and Macros for application automation.

Event-Driven Programming in Visual Basic

The interaction between the above three elements is the basis of Visual Basic’s event-driven programming model. The VB programming workflow typically follows a particular pattern:

  1. Creating window(s) that can accept an input and display the result of an input.

  2. Anticipating and accepting user input, i.e. an event.

  3. Relaying the event through a message that instructs the program to perform some action, the result of which is shown in either the same or a new window.

For example, you might create a dialog box that shows a simple ‘Hello, World!’ message when a button is clicked. Here, the dialog box would be the window and clicking the button would be the event which sends a message to the program to display the ‘Hello, World’ text.

Event-driven programming requires the programmer to anticipate the user’s actions. It is unlike most programming languages since it does not follow a linear path; the user may interact different parts of the program at the same time through separate events. This helps programmers create applications that are much more dynamic – quite like Microsoft Windows itself.

Working With the Visual Basic 6.0 IDE

Understanding Interactive Development

An IDE (Integrated Development Environment) is an application that helps programmers build, edit, and even compile code. The Visual Basic 6.0 development environment is often compared to an IDE as it not only supports a GUI for developing and editing programs, but also includes a compiler and debugger.

The IDE is also where Visual Basic differs from other programming languages. The standard programming procedure involves three steps, namely writing the program, compiling, and testing for errors. Visual Basic, on the other hand, compiles code as you write it. This means that the VB IDE can indicate errors as you make them. This handy feature is called ‘interactive development’ and it makes Visual Basic especially useful for beginners.

Using the Visual Basic 6.0 IDE

The VB IDE looks like any other software program. It has toolbars, menu bars, a floating toolbox, a project manager, a form designer and a properties explorer. While exploring each of these elements in-depth is beyond the scope of this tutorial, we will cover some of the essential components below:

1. Form Designer: The form designer sits right at the center of the VB IDE. It is the heart and soul of the Visual Basic GUI development process. This is where you can drag and drop dialog boxes, pictures, and other graphical elements to complete your project. Familiarize yourself with the form designer; you will be using it extensively in your programs.

2. Properties Explorer: The properties window allows you to view and edit properties associated with any particular form or control element.

3. Object Browser: The object browser is a list of all modules and classes that you can use in VB. This includes both pre-built as well as custom-built modules and classes.

4. Code Editor: Sometimes, you may have to get your hands dirty and write some real code. The code editor window comes in handy in such situations. There is a separate code editor window associated with each form and control element.

5. Debug Windows: This includes the locals and watch windows. These are used for debugging applications

6. Toolbox: The floating toolbox gives easy access to common VB controls such as textbox, command button, list box, etc.

7. Form Layout Window: This little window helps you position the form where you want to – quite useful for making design changes on the fly.

8. Project Window: The project window shows all the files and folders included within the project.

Go ahead – try creating a new project and using the toolbox to create a form element. You’ll be surprised by how easy it really is! If you’re still unsure, try the programming for non-programmers course to familiarize yourself with coding basics.

We’d love to hear your thoughts and opinions on Visual Basic 6.0 basics. Share them with us in the comments below!

Page Last Updated: February 2020

Excel VBA students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy Business.

Request a demo