devxlogo

We are an award-winning tech entrepreneurship website where trusted experts can provide value globally.

Since 1998, DevX has helped people start businesses, build websites, and provide enterprise technology to people globally. Interviewing the likes of Microsoft’s co-founder, Steve Ballmer, the publication brings comprehensive, reliable, and accessible insights to the Internet.

devxlogo

Trusted for 26 years

Over 30K Articles

1M+ Readers

Expert-reviewed

10K+ Tech Terms

As seen in:

microsoft logo
business_insider_logo
wired_logo
berkley
arstechnica_logo
hackernoon

The Latest

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

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

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

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

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,

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

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

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

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

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

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.

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

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

Speed Up List Box Updates

When adding a large number of items to a list box, you can greatlyspeed up the process by disabling redraws of it. A quick call to SendMessagedoes the trick. Sandwich

Use the Right Tool for the Job

If you’re running into a roadblock in a particular section of yourprogram, step back and take another look at what you’re doing. There’sa good chance you’re using the wrong tool

Drawing Directly on the Form Saves Resources

You can drop labels and frames out of your application (and their accompanyingresource and memory usage) by writing a small routine to use Print andLine that draws directly onto your

Make a Gauge with MicroHelp’s Controls

You can make a beautiful gauge by combining two MicroHelp controls.Place a Mh3d control onto your form and set the inner bevel just insideof the outer bevel. Place a Mh3dCommand

Validating Text Entries When a DataCombo Loses Focus

When setting focus to another control, the DataCombo in Sheridan’sData Widgets can be forced to validate the text portion against its listby referencing the DataCombo’s IsItemInList property as follows: If

Use the Shortest Variables

Use the shortest data type you can for variables. If you’re going tobe counting in a loop from 1 to 10, for instance, use an Integer not aDouble.

Using the MH3D Calendar Control for Date Math

One of the great unsung heroes in MicroHelp’s VBTools is the Mh3dCalendarcontrol. Place a hidden calendar control on one of your main forms. Withthe .Day, .Month, .Year, and .DateFormat properties,

Using LostFocus Events with Command Button Properties

If you’re using LostFocus events but would also like to set the Defaultor Cancel properties for command buttons, you’ll run into a confusing situation.Those properties trigger the Click event when

Sorting Data Within a Datagrid

Data is sorted by using the “ORDER BY” clause in a SQL statementand then assigning the SQL statement to the RecordSource property of thedata control that the DataGrid is bound

Keyboard Shortcuts

Yes, these shortcuts are in the manual, somewhere, but it’s helpfulto brush up on them. Using keystrokes is usually faster than using themouse to do the same thing. Photocopy these

Build Your Own Floating Toolbar

Ever wanted a floating toolbar? To make one form “owned”by another, all it takes is a simple API call. Afterwards, the owned formwill float above the form that owns it,

Change the Container of a Control

I use bounded text boxes within the picture control but they act asif they belong to the form. Here’s how to make them act as if they belongto a container

Use Smaller Graphics to Save Resources

Larger bitmaps used for .ListPicture/ListPictureSel properties in Mh3DListconsume proportionally larger amounts of resources. Also, avoid using 256-colorbitmaps in controls–they too consume more resources.

Giving Forms a 3-D Look

It’s not widely known that you can use CTL3D.DLL (or CTL3DV2.DLL) togive your VB forms the same 3-D look of Microsoft’s Office suite of applications.First, your app must register with

Indenting Code Blocks

You can highlight a block of text in the code window and press theTab key to indent the block or Alt-Tab to unindent it.