Many programmers often complain that they are confused by all the "Basics" found in Microsoft products. In this section, I will try to clear up this confusion for you. Each of the different flavors of VB has a specific purpose, so choosing the correct one is important.
When should you use any one of these versions of Visual Basic? The answer depends on your needs. Use as a guide to help decide which version is best for you.
Table 25.3 - Choosing the Right Language
Language | Usage |
---|---|
Visual Basic | If your application requires the maximum amount of flexibility, or if you need to create a stand-alone executable or shared component, then Visual Basic is right for you. |
Visual Basic for Applications | If your application depends on an application that uses VBA as its macro language (for example, Excel or Word), then use VBA. Unless your users do not have one of these products, VBA is probably the right choice for your application. Remember that VBA includes support for OLE Automation, so your possibilities are virtually endless. (For more advice, see the Note that follows this table.) |
VBScript | If you're programming a Web page or programming in Outlook, then you'll have to use VBScript. Although VBScript isn't as feature-rich as VB or VBA, it still can be used to write sophisticated applications. |
![]()
If you're developing a custom application and your customer doesn't have Microsoft Office 97, consider buying that customer a copy. Even the smallest customized solution can cost several thousand dollars, so including Office (typically, you can purchase a competitive upgrade copy for about $199) can save weeks or months of development time.
While the choice between VBA and VBScript is clear, knowing when to use VB instead of VBA is a little more complex. The best way to think of VB is as an object factory. VB is best suited for creating objects (for example, custom controls, shared OLE objects, and so on). VB is also the better choice for advanced custom solutions that need to be both fast and stand-alone. VBA, on the other hand, is most useful for automating or adding features to powerful products such as Microsoft Excel or even your Web pages in Internet Explorer.