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

Identifying a Generic Control at Run Time

When a procedure can operate on multiple types of controls, youcan use VB’s TypeOf function to determine a control type at runtime: Function myFunc(ctl as Control) ‘ This code works

Hexadecimal Color Constants

Properly designed Windows programs should change their own colorsaccording to the system colors. One of the reasons why developerstend to forget that part of design is that it is not

Undocumented Feature Logs Jet Queries

Jet 3.0 includes an undocumented feature that lets you log Jet’soptimization plan of queries. To enable this feature, you mustcreate this registry key using Windows’ RegEdit program: HKEY_LOCAL_MACHINESOFTWAREMicrosoft _ Jet3.0EnginesDebug

Simplifying the Condition-Part of an If statement

When you write an If statement such as: If Category = “CM” or Category = “M2” or Category = “P1” or Category = “ZZ” thenProcessEmployeeEndif it can be simplified by:

Eliminating the If Statement Wherever Possible

If you have to assign True or False to a variable after testinga certain condition, then the If statement may be done away withaltogether. For example, if you have something

Avoid Redundant Execution of Code

Most collections are zero-based. The COUNT property returns thenumber of members of a collection, as opposed to the highest membernumber. So when we see code that loops through all the

Set Forms to Nothing with Caution

It’s a good idea to set your form variables to Nothing to recoverall memory that was allocated for the form module. Executing SetForm1 = Nothing for a loaded form, however,

RegEdit Addition “Automation”

This sample file from Microsoft allows a more automated Windows95 Registry Addition. You can create a similar file in Notepador your favorite text editor, replacing the appropriate entriesin place of

Sizable Forms Without a Title Bar

If you set a form properties caption to “” and controlbox to False, then a form with borderstyle 3 (fixed dialog) willdisplay without its title. Unlike borderstyle zero (none), itkeeps

Securing a Jet Database the Right Way

To secure a Jet database, you must purchase Access 2 for VB3/VB3-16or Access 95 for VB4-32 and follow these steps: Use the Access Workgroup Administrator to create a new workgroupwith

Editing the Regular Grid

The regular grid that comes with Visual Basic cannot be editeddirectly. However, this problem can be easily circumvented withone line of code: Private Sub Grid1_KeyPress(KeyAscii As _ Integer)Grid1.Text = Grid1.Text

Blanks in the Masked Edit Control

The Microsoft Masked Edit control only allows input that matchesthe mask. Similarly, you can only set the Text property to a stringthat matches the mask. If you have a mask

Enforce Uppercase Characters

Do you want to facilitate the user to enter only uppercase charactersduring editing in text boxes and other edit controls? Irrespectiveof the position of CAPS LOCK key, this code in

Add ‘Type Ahead’ Functionality to Combo Boxes

You can add ‘Type Ahead’ functionality to the standard VB ComboBoxcontrol with this subroutine: Sub ComboTypeAhead(Combo As ComboBox)Dim i As Integer, _ KeyString As String, _ KeyLen As IntegerKeyString =3D

Tab Order with Labels Attached To Controls

In order for a label to be associated with a control (such as a textbox) for using hot keys, they must be in TabOrder sequence, the label beingone more than

DBGrid Automatic Configuration

If the layout of VB4’s DBGrid is not changed at design time, it willautomatically configure to a new record set when the Data control is refreshedwith a new RecordSource.

Unloading The Server From Memory

Shut down the instance of Visual Basic that uses the compiled in-processOLE server to unload the server from memory. Changes to the in-processOLE server will not be seen until the

Beware Of Design-Time DDE Links

When using DDE Links at design time, the link will be temporarily cutwhen the program is run. Some, but not all, programs will reestablish theconnection.

Speed Crystal Reports

If Crystal Reports’ speed is lacking although your report contains nolarge graphics or large numbers of groups, change these two lines in yourCRW.INI file to solve disk swapping problems: MaxRecordMemory=0MetapageSpillLimit=100

VB 4.0 Keyboard Shortcuts

Note that some key combinations are different from those for VB 3.0:Ctrl-T–Custom Controls. Ctrl-E–Menu Editor. Ctrl-F–Find (Unchanged from VB3). Ctrl-H–Replace (H? Yes, H! Go Figure!).

Printer Object EndDoc Resets FontName

The Printer object’s EndDoc method resets the FontName property. Ifyou want your application to print separate documents, invoking EndDocat the end of each, set the FontName before printing the first

OLE Server Object Manipulation

Don’t return references to Form and Control objects from your OLE server.Rather, provide wrappers for the properties and methods of forms and controlsif they must be manipulated by your OLE

Append a String to a Text Box

Use this code to cause a TextBox control to automatically scroll down as you concatenate new text: ””Select the end of the text MyTextBox.SelStart = Len(MyTextBox.Text)””Put the new text thereMyTextBox.SelText

Use The Most Specific Type Available

Instead of declaring an object As Object, use the specific object type, such as CTask. This improves performance by minimizing the OLE lookup requirements.

Use

Use an ampersand (&) instead of a plus sign (+) when concatenatingstrings. Depending on the data type of the operands, using the plus signmay result in an addition.

Watch What You Pass To Your OLE Servers

Don’t use any objects in the Visual Basic object library as parametersor return values for exposed properties or methods in public classes. Theseobjects are not intended to be used from