August 22, 1997

Effective Error Handling

While working with classes in VB 4.0, we found that the errors raised from our classes were not being trapped at the form level. We used “On Error Resume Next,”

Stored Access Queries Speed Response Time

In general, stored Access queries are faster than embedded SQL in your VB application. It can be a great benefit to be able to send parameters to the query directly

Suppress Spaces in a Text Box

To prevent users from typing spaces in a text box, include this code in the KeyPress event of the text box: Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 32

Don’t Forget Your References

If you get the error “User-defined type not defined” on a line where you are declaring a database, go to Tools, then go to References, and select the appropriate DAO

Is Mail Running?

Use this code to quickly determine whether Microsoft Mail is currently running: Declare Function GetModuleHandle Lib _ “Kernel” (ByVal lpModuleName As String) As IntegerFunction IsMicrosoftMailRunning ()On Error GoTo IsMicrosoftMailRunning_ErrIsMicrosoftMailRunning =

Find the Name of the Windows or Windows System Directory

You can quickly find the name of the Windows or the Windows System directory. Just pass “WindowsDirectory” or “WindowsSystemDirectory” into this function: Declare Function wu_GetWindows_ Directory Lib “Kernel” Alias _

Automatically Resize Controls

Sometimes you need to change the size of controls by changing the size of a container. For example, try this: Private Sub Form_Resize() Picture1.Align = vbAlignLeft Picture1.Align = vbAlignTopEnd Sub