Visual Basic. (Microsoft Visual Basic)(column) (Evaluation)
by George Campbell
With Windows 3.0 just 18 months old, the rush to create programs for that operating environment is on. Until now, though, writing software for Windows was difficult, to say the least. Visual Basic changes all that. With its introduction, Microsoft has made it easy for anyone with BASIC programming experience to create software for Windows 3.0.
While it takes about 100 lines of code using C and Microsoft Software Development Kit (SDK) to do something as simple as print hello on a Windows screen, Visual Basic can do the job with one simple line, using the old familiar Print command. Simple ideas often herald revolution!
Priced at $199, this new programming environment begins to prove its worth right out of the box by installing in just a few minutes. The included interactive tutorial takes you through the first phases of creating a Windows program, and full-scale online help supplements the two manuals. With the familiar Windows dialog boxes and menus, you'll soon be comfortable with the interface.
Since you learn new programming languages best by example, Microsoft offers plenty of examples in its manuals and tutorial. You also get several sample programs, ranging from a simple card file to an outstanding icon viewer and editor. You can use all or part of these samples any way you like, without worrying about paying royalties. Finally, Visual Basic can create EXE files, unlike ToolBook or other comparable authoring systems. You'll still need VBRUN100.DLL, Visual Basic's runtime dynamic link library, but you can distribute it free with your programs.
If you're familiar with QuickBASIC, also from Microsoft, writing code in Visual Basic will present no real challenges, but that's where the similarity ends. Visual Basic works in a way that's completely different from what you're used to, and that's its charm.
Instead of the laborious process of creating a user interface in another language, Visual Basic lets you simply draw the interface on the screen. Starting with an elementary window, which Microsoft calls a form, you use a toolbox similar to those in drawing programs to add controls--command buttons, check boxes, text and picture boxes, and other elements--to the form. Your program can have several of these forms.
Sizing and positioning forms and controls is as simple as clicking and dragging the mouse. Visual Basic even includes list and combo boxes like those in most Windows applications.
There's more. Since any Visual Basic program uses all the facilities of Windows 3.0, you won't have to worry about printer or display availability. You can also use the Windows Dynamic Data Exchange (DDE) functions to form links with other programs or call on Clipboard for cut-and-paste operations.
More than just attractive objects, the icons from the toolbox provide you with the functions that they illustrate, and you don't need to write a single line of code. For example, a text box automatically provides normal text-editing functions, from word-wrap and text selection to keyboard cut-and-paste operations. Similarly, adding a file list box to your form automatically gives you the ability to select files when your program runs. A menu design option in the Visual Basic menu lets you design a menu bar, complete with nested menus, by simply typing in menu names.
For each object on the screen, you can set options, ranging from background color and border type to text fonts and the type of mouse pointer used in the display. Any object can be visible or invisible, and you can change most options with simple commands as your program runs. Adding graphic images is a simple matter of loading a bitmap file into a picture object. All this means that you spend your time designing a terrific interface for yourself or other users without worrying about how the interface works.
Once your interface looks the way you want, you begin to write the program itself. Here, too, Visual Basic will surprise you. Using what Microsoft calls event-driven programming, you write code to tell Visual Basic what to do when the user takes some kind of action, such as clicking on a command button, pressing a key, or clicking the mouse. When you're designing your program, a double click on any object takes you to an editing screen. Then, you choose an event from a drop-down list and write the code needed to handle that event. For example, to tell your program what to do when a user clicks on a command button or a menu entry, yo select the Click event and then write your code, using language and syntax similar to that in QuickBASIC.
Unlike QuickBASIC, however, some elements of the Visual Basic language feel both familiar and different at the same time. Although Visual Basic isn't an object-oriented language in the technical sense, it does deal with objects. For example, the familiar old Print command must be preceded by the name of the object. To print to the printer, the command Printer. Print is used. To print to a text box object, the command would be Text 1.Print. It's easy to get used to this new syntax, however.
You'll miss some old familiar QuickBASIC commands such as Play, Inkey$, and Chain. These missing commands aren't needed in most programs, however, and Visual Basic offers its own equivalent commands.
Some missing language features, however, make Visual Basic programming more difficult. While you're in a loop in a program, you can't watch for a keystroke and then exit from the loop. Also, there's no way to determine what line your cursor is on in a text-editing box. While you can write your own routines to handle these needs, they'll run slower than built-in commands.
Also on the negative side, locating a particular part of your program when you're editing sometimes proves difficult. Rather than keep your code together, Visual Basic scatters it into many separate modules. Before long, though, you'll learn the system and forget this minor inconvenience.
When it's time to debug your program, Visual Basic has all the tools you need, ranging from stepped execution and breakpoints to the ability to restart the program after making changes. And your Visual Basic programs run quickly, so you won't be slowed down when using programs you've written.
One of the best things about Microsoft Visual Basic is that there are already a large number of add-ons to help both beginning and advanced programmers get more from the product.
Microsoft itself has led the way here with its Control Development Kit, which allows advanced Windows programmers to create custom buttons and other controls.
Also from Microsoft is the Windows Help Compiler, which gives both beginning and advanced VB programmers all the tools they need to create online help that's the equal of any Windows program's online help.
Both products are available from Microsoft, One Microsoft, Way, Redmond, Washington 98073; (206) 882-8080. Control Development Kit and Windows Help Compiler sell for $49.95 each.
If you have a yen to create your own programs for Windows 3.0, Microsoft has opened the door wide with this amiable programming environment. Visual Basic can turn anyone familiar with BASIC into a Windows programmer almost instantly.