August 21, 1997

Data Access Speed

When you connect to remote servers, always use tables attached to theserver through Access. This will significantly speed up your retrievaltime. Once a table is attached to a remote server, the whole structureof the table is brought down to your local machine. If it is not attached,the table structure is

Avoid Using Variants

Variants take more memory and it’s slower to get/set their values thanother data types. Option 1 will run slower than Option 2. Option 1: Dim iLoop As Variant For iLoop = 1 To 100 Print iLoop Next , Option 2: Dim iLoop As Integer For iLoop = 1 To 100

Use the VB Knowledge Base

Get the Visual Basic Knowledge Base from Microsoft. It contains hundredsof ideas (with code samples). I use it daily to get my job done (and findout new things to try that I never would have dreamed possible). You canget this file from the Microsoft Download Service or from CompuServe (GOMSL).

Hiding MDI Children

MDI children can be hidden! Although VB doesn’t directly supportthis, you can use the ShowWindow API call to do so. A simple call likethis will do it: Declare Function ShowWindow Lib “User” _ (ByVal hWnd As Integer, ByVal nCmdShow _ As Integer) As Integer Global Const SW_HIDE = 0 Ret%

Make MDI Children Invisible on Loading

Contrary to popular belief, an MDI child does not need to be immediatelyvisible at load time. If the Visible property is set to False at designtime, the child will not become visible until either the last lineof its Form_Load event or another statement (such as Show) causes it todo so.

Never Have an Untrapped Error in VB

To prevent untrapped errors in VB, put an error handler in the codefor every control/form’s events. Unless you want more granularity, youwon’t need to trap errors in function or module routines.

Load VBX/OCX/DLLs in the Windows System Directory

It’s best to load all shared (or public) VBXs, DLLs, and OCXs in theWindows system directory. Doing so prevents component conflicts betweenshared components that are loaded in the wrong places. By the way, Windowslooks in memory for loaded code modules from VBXs before it looks in theWindows system directory.

Quickly Evaluate an Expression or Variable

Here’s how to quickly evaluate an expression or variable: While indebug mode, use the Add Instant Watch dialog to quickly see the currentvalue of an expression in your code. Highlight the variable or expressionand press Shift-F9, which opens this dialog. You’ll see the expression,plus it’s current value. This is much

Find Lost Controls

If a control gets lost on your form, you can select it by choosingits name from the drop-down list at the top of the properties window. Setits Left and Top properties to 0. Choose Bring To Front from the Edit menu.If it’s still lost, choose Delete from the Edit menu

No more posts to show