Easy Windows programming. (Microsoft Visual Basic, combination screen design toolkit and BASIC compiler) (evaluation)
by Clifton Karnes
The release of Microsoft Visual Basic (Microsoft, One Microsoft Way, Redmond, Washington 98052; 206-882-8080; $199) means one thing: fast and easy Windows programming!
Visual Basic (VB) is the combination of a screen design toolkit and a full-featured BASIC compiler. With it, you can create real Windows EXE files that will run on any Windows-based system and look great.
The VB programming environment is a functional masterpiece, consisting of a main window, a toolbox window, a project window, and a form window. The main window is the control center with a menu bar and a properties bar.
Below the main window at the left is the toolbox--a palette of controls. At the right is the project window--an automated make file that keeps track of all the program elements in each project. In the screen's center is the form window--the canvas on which you create your VB program.
To create a VB program, you begin by selecting controls from the tool box and placing them on forms. The toolbox provides all the standard Windows controls, including command or push buttons, option or radio buttons, check buttons, text fields, labels, combo boxes, list boxes, pictures, scroll bars, and selectors for drives, directories, and files.
Every control in the toolbox has a list of properties displayed in the properties combo box on the properties bar of the main window. And each property has settings you select or type in using the settings combo box to the right of the properties box.
To give an example of a control, property, and setting, let's look at a command button. All command buttons have a caption property--a label that appears on the button--which can have any number of settings. A button might have a caption setting of OK, Run, or Exit, for example. This same button might have its background color property set to gray.
After you've chosen and arranged your controls and set their properties, you're ready to attach code to the controls.
VB, like Windows itself, is event-driven. A model VB program simply responds to events--like clicking the mouse on a control or pressing a key--the user initiates.
Just as each VB control has a group of properties that can be set, it also has a group of events to which it can respond.
For example, a command button can respond to a click event. It you want this button to do something when the user clicks it, you write a subprogram, or event procedure, to handle it. To write an event procedure, double-click on the control, and a code window pops up. Choose the event you want from the combo box on the procedures bar of the code window.
After writing your first event procedure, you can test the program by choosing Start from the Run menu. You can halt execution at any time and test code fragments in the immediate window, or you can singlestep through your program.
If you're satisfied with your VB program, you can create an EXE file by selecting Make EXE File from the File menu. Your VB EXE program will require a 270K runtime module, VBRUN 100.DLL (which you can distribute free of charge), but the EXE files themselves are very small and quite fast.
One of the most exciting things about VB is that its environment can be extended. The most interesting way to extend VB is with custom controls. These extensions are special-purpose or enhanced Windows controls that appears on your toolbox alongside standard VB controls. Some give more power to standard controls; others introduce completely new control types.
The other way VB can be notably enhanced is with custom DLLs. These libraries are like the special link libraries BASIC programmers have been using for years, but with Windows, DLL code can be dynamically linked in at runtime.
There are already a large number of these extensions available, and next month, I'll look at the best of the VB custom controls and libraries.