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

A Reminder You Can’t Miss

I often have several programming irons in the fire at one time. Jumping back and forth from project toproject, I sometimes lose track of where I left off within each

Consistent Version Numbers

For consistency’s sake, use this routine wherever your version numbers appear in code: Public Function GetMyVersion() As String ‘ Turn version info into something ‘ like “1.02.0001” Static strMyVer As

Right-Align Controls on Forms

When creating resizable forms, I like to place command buttons in either the upper-right or lower-rightcorners. For example, on data entry forms, I place record navigation buttons on the lower-left

Keep Track of the Last Form

In your MDI application, you might have many child forms and need a form to go back to the form thatcalled it. In each child form, declare this variable: Public

Resize the Drop-Down List Area of Combo Boxes

VB doesn’t provide a ListRows property, so if you need to display more than eight default items in a combobox drop-down list, use this procedure to increase the size of

Val Doesn’t Work on Formatted Numbers

Beware of the Val() function. It doesn’t correctly recognize formatted numbers. Use CInt(), CDbl(), and soon instead: FormattedString = Format(1250, _ “General”) ‘ = “1,250.00”Debug.Print Val(FormattedString) ‘ prints 1 !Debug.Print

Format or Copy Diskettes Using Windows API

The Win32 API includes a pair of functions that let you format and copy diskettes from your programs: Private Declare Function SHFormatDrive _ Lib “shell32” (ByVal hwnd As Long, _

Show Free Memory Under Win32

If you want to show your users the available memory on the machine, and you’re moving from 16 bits to 32bits, you’ll find the API function GetFreeSystemResources has been dropped.

A Smart ID Generator

I wrote a unique error-proof number generator that greatly simplifies the checking of clients’ accountnumbers or other IDs used by your application. I use it in conjunction with the CheckForValid

Shelling MS Internet Mail

If you are using the new mail program that can be downloaded for free from Microsoft’s Web site, you can run it from within your program. Simply add this command

Cheap Graphic Buttons

You can use the Wingdings font to put simple graphics on a standard command button. Put a standard command button on a form, and in the Properties window, change the

Hidden MDI Children

“Hide” an MDI child form with a non-sizable border style (0 or 1) using this code in the MDI child’s Form_Load event: form1.Move form1.Left, form1.Top, 0, 0 Use a label

Get/Put Arrays to Disk

The API functions “_hwrite” and “_hread” can be useful for writing arrays directly to files and, at some later time, reading these files directly into arrays having the same structure.

Refer to Columns in a DBGrid Control

Columns in a DBGrid control are bound to database fields. However, the index number of a column doesn’t tell you which field it represents. Therefore, referring to DBGrid1.Columns(0).Value is not

Addendum to “Remember SWAP?”

The tip “Remember SWAP?” [“101 Hot Tech Tips for VB Developers,” Supplement to the August 1996 issue of VBPJ, page 13] has a common error. This line actually creates three

Where Does It End?

When using the line-continuation character facility-the combination of a space followed by an underscore (_) used in the development environment to extend a single logical line of code to two

Dispelling Performance Myths

Omitting the counter from a Next statement does not speed up a For loop. Calling a procedure in a BAS module is not slower than calling a procedure contained in

Make Column Headers the Perfect Width

When you’re dynamically adding ColumnHeaders to a ListView control at run time, you may not know how long the text for the header will be, so the user must readjust

Use RLEs to Reduce EXE Size

Many programs use a splash screen to display the logo of the program. The logo is usually made by an image. You used to store it as a BMP (uncompressed)

Obtaining System Date Format

The DateCheck function is useful when you use the Masked Edit control for entering the date according to the system format. Some countries use the MM/DD/YYYY format, and other countries,

Trimmed to Fit

This piece of code trims long file names to fit into forms captions, text boxes, and other limited spaces. The code allows you to specify the number of characters a

Prevent Unwanted Recursion

A bug affecting the Sheridan 3D Controls appears in VB 4.0a. I don’t believe it was in 4.0, and I am certain it was not in 3.0. In any case,

“File Exists?” Revision

To adapt the tip “File Exists?” (see “101 Hot Tech Tips for VB Developers,” Supplement to the August 1996 issue of VBPJ, page 7) to a directory list box, it

Long File Names Can Be Confusing

If you want to open Paint with a file from your application, it’s better to convert the path of the file you want to open from long to short names.

Calculate Age Using DateDiff

Use the function DateDiff to calculate an individual’s exact age based on birth date. DateDiff first calculates the total number of days an individual has been alive and then divides

Clear the Clutter

Provide your users with a quick way to clear their “messy desktop” of extraneous forms by dropping this code into the Click event of a command button: For Each Form

Please Stop Printing!

Sometimes I want to print data from a recordset to a report, reading and printing each record. However, it’shard to interrupt that process before it sends all recordsets to the

Evaluating Elapsed Minutes

You might need to keep track of the total minutes between one date or time and another. To get the totalminutes, use a line like this: lTotalMinutes = Minutes(Now) –

Show an Hourglass When Processing Data

Have you ever forgotten to add code to set the MousePointer back to its default at the end of a procedureor function? This technique simplifies showing and resetting the MousePointer