Visual Basic Concepts

Designing for Performance and Compatibility

In an ideal world, every user of your applications would have a computer with the fastest possible processor, plenty of memory, unlimited drive space, and a blazingly fast network connection. Reality dictates that for most users, the actual performance of an application will be constrained by one or more of the above factors. As you create larger and more sophisticated applications, the amount of memory the applications consume and the speed with which they execute become more significant. You may decide you need to optimize your application by making it smaller and by speeding calculations and displays.

As you design and code your application, there are various techniques that can be used to optimize the performance. Some techniques can help to make your application faster; others can help to make it smaller. In this chapter you will learn some of the more common optimization tricks that you can use in your own applications.

Visual Basic shares most of its language features with Visual Basic for Applications, which is included in Microsoft Office and many other applications. Visual Basic, Scripting Edition (VBScript), a language for Internet scripting, is also a subset of the Visual Basic language. If you’re also developing in Visual Basic for Applications or VBScript, you’ll probably want to share some of your code between these languages.

This chapter discusses the differences between the three versions of the Visual Basic language and provides some tips for creating portable code.

Topics

Understanding Optimization

An introduction to optimization.

Optimizing for Speed

Techniques for making your application more efficient.

Optimizing for Size

Techniques for reducing the size of your application in memory and on disk.

Optimizing Objects

Techniques for optimizing the use of objects in your application.

Compiled vs. Interpreted Applications

A discussion of the pros and cons of native-code executables.

Compatibility with Other Microsoft Applications

Information on sharing code between versions of Visual Basic.

Sample application

Optimize.vbp

Many of the optimization techniques in this chapter are illustrated in the Optimize.vbp sample application which is listed in the directory.