Programming Windows: Visual Basic Takes Over the World (Premium)

To understand why Visual Basic was such a sensation, consider again how horrible it was to create even the simplest application using the C programming language and the Windows API: The modern example of a basic Charles Petzold hello, world-type application that I provided in Programming Windows: Hello, Windows (Premium) is almost 100 lines of code, is hard to read and understand, and is not particularly scalable. But a Visual Basic version of this same application, as I demonstrated in Programming Windows: Hello, Visual Basic (Premium), can be made without any code whatsoever. A version that does use code can be as short as two lines of user-created code.

That’s amazing. But both versions of the Hello, Visual Basic application only hint at the inherent superiority of this environment, especially when building application user interfaces. Designed to be as compatible as possible with Microsoft’s earlier Basic language efforts, in particular QBasic/QuickBasic, the Visual Basic language itself was simple and easy to read (and write). It utilized some basic (ahem) Object-Oriented Programming (OOP) techniques that made particular sense for those creating a GUI-based Windows application. And unlike with Windows API development, handling the events that drove the Windows experience wasn’t just simple in Visual Basic, it was obvious and even fun.

At a high level, the process was similar. As with a C-based Windows API application, Visual Basic applications had an entry point and usually had a single or primary window. They also processed messages related to events, which could be user-generated (a mouse click, perhaps) or system-generated. In both cases, it was up to the developer to determine which events they would respond to.

But where Windows API-based applications required a complex message processing loop, Visual Basic handled event processing in a more modular and manageable way, isolating the developer from the intricacies of the underlying system. Visual Basic abstracted the difficulties of the Windows API into a system that was easier to learn, easier to use, and easier to master.

A simple example.

When you started Visual Basic, you were presented with a basic application consisting of a single resizable window, which VB idiosyncratically called a form because of its roots in Alan Cooper’s Ruby. This act alone represented many dozens of lines of code that never needed to be written. But the real strength of Visual Basic came via the toolbox of controls---labels, text boxes, buttons, and many others---that one could drag and drop and arrange on the form. And with the ease with which one could handle the events that would happen to that form and its controls.

Consider a basic button control. As even a non-programmer would know, the most obvious event that happens to a button is a mouse click. And so Visual Basic would generate the code for a click event handler if a command button, as VB called it, was placed on a...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC