The Latest

DevX

Clean and Compact Your Code

The last thing you should do before creating your final EXE is clean your code. This tip explains how to clean the garbage from your project that is sometimes left

DevX

Scrollable Viewport for a Picture

It’s easy to make a scrollable viewport for a picture in both VB3 VB4. In addition to a picture, you can also use other objects that grow. First, create a

DevX

VB 4.0 Add-In Error Messages

The ability to write add-ins under VB 4.0 is a significant addition to the developer’s toolbox. However, writing and distributing add-ins can be fraught with many a mind-boggling experience. One

DevX

Directory References in Code Profiler

The Code Profiler does not properly handle relative directory references in the VBP file. If the file looks like this, Code Profiler aborts trying to process the CRW45 file: Module=PASSMAN1;

DevX

OLE Automation Versus Standalone Mode

There you are, creating an OLE server in Visual Basic. You go to Options in the Tools menu, select the Project tab, choose “OLE Server,” and click on OK. After

DevX

Protect Your Screen Saver From Restarting

When you create a screen saver in Visual Basic, you may sometimes utilize the command-line options such as “/s” to start a screen saver directly or “/c” to run the

DevX

Track Modem Use by Other Applications

With applications increasingly using modems, it is quite possible that users will start your application, forgetting that another application is already using the modem-like a fax machine, for example.The MS

DevX

Branding a Jet MDB File

This routine allows a hidden table to be appended to the Tables collection in an MDB file. I use the table name as a brand or stamp. During development, I

DevX

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,”

DevX

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

DevX

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

DevX

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 _

DevX

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 =

DevX

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

DevX

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

DevX

A New Data Programming Style

While working on VB projects with associated Jet databases, I found that I was creating a lot of individual handling functions for reading, writing, and validating data. It was hard

DevX

Use the MS Draw Applet to Draw Lines and Shapes

Rather than using Visual Basic’s line and shape objects when drawing complex graphic backgrounds on forms, use the MS Draw applet included with most Microsoft products to draw a Windows

DevX

Copying Menu Objects Between Forms

One problem that occurs frequently is taking the menu structure from one form and placing it in another. Although my method of dealing with this dilemma requires a little effort,

DevX

ODBC Error Display

I have seen many posters in the VB newsgroups that say they have received an ODBC error message such as 3146, but can’t figure out why they got the message.

DevX

Set Cursor to Control by Default

Sometimes it is useful to set a cursor to determine control when a form is loading-after the form is done loading, the cursor stays on the control you have ordered:

DevX

A Better Substitute for GetModuleUsage

To synchronously shell an application from a 16-bit VB application, some people write code like this: Const HINSTANCE_ERROR% = 32Dim hInstChild As Integer’Shell program, if Shell worked, enter loophInstChild =

DevX

Entering Scientific Formulas

I have developed this technique to use when I program long formulas. First, I declare descriptive variables for the mathematical elements. I prototype the formula using the digit “1” as

DevX

Create Queries On the Fly

Use VB’s string-concatentation operator (&) to incorporate user input into SQL queries at run time. Assume, for example, that cboField is a combo box containing a list of fields in

DevX

Speed Tips

Reading data into and out of a VB program is straightforward. Most folks use the Input and Put statements in a For…Next loop. However, this straightforward technique takes time. Because

DevX

Use an ICO File as a Mouse Pointer

If you want to use an ICO file as a mouse pointer, set the MousePointer property to 99-Custom. Then load the icon into the MouseIcon property: Text1.MouseIcon= LoadPicture(“c:vbiconselements_ earth.ico”) For