General Issues
- Layer your applications to take advantage of generic, re-usable procedures. In our experience, this is one of the most important optimization techniques: it makes possible the substitution of C or object code for Visual Basic, and allows you to leverage your most productive coders by having them concentrate on building components.
- Avoid custom controls by using built-in Visual Basic controls whenever possible. Built-in controls are included in VBRUN300.DLL, so use less system memory and disk space than other custom controls.
- In general, excessive control use can slow down an application; here are a few ways to economize on control resources:
- Print directly to forms rather than use control labels.
- Whenever possible, use the graphical controls (Line, Shape, Label), and substitute the Image control for the Picture if possible.
- Rely on Windows API calls as much as possible to accomplish what you might otherwise do with controls. For example, rather than use the Common Dialog control, Windows common dialogs can be called with completely generic Visual Basic code — you can even download routines from CompuServe to do this.
- Use control arrays instead of multiple controls. Not only are control arrays more flexible, but forms with many controls will consume much less memory if control arrays are used.
- If possible, avoid OLE automation. Although elegant and promising, this is one of the most resource and memory intensive operations available in Windows, especially if you're automating mega-applications like Word or Excel. Try using SendKeys as an alternative.