devxlogo

Tip Bank

Prevent Errors When Using GetSetting

Using Visual Basic’s GetSetting function might cause an error, particularly in certain situations when using itunder 16-bit operating systems with INI files. If there’s no specific entry in the INI

The Mid Statement and Function

You’re probably familiar with the Mid function, which returnsa substring of a specified number of characters from its stringargument. But are you aware that Mid can also be used to

The Move Method is Faster

To move a control or form to a new location, you can set the Leftand Top properties to new values: frmCustomer.Left = frmCustomer.Left + 100 frmCustomer.Top = frmCustomer.Top + 50

Debugging Events When They’re Acting Funny

Use Debug.Print “Entering event …” without breakpointsto trace events if they seem to act funny. Don’t use break points withMsgBoxes–they can alter the event sequence.

Get Rid of Leading Zeros

Eliminate “leading-zeros” in a text string in this interestingway: instring$ = “00030” ‘ set the string with some leading-zeros’ now to get rid of them….instring$ = CStr(Cint(instring$))’ now instring$ should

Fading Colors

Use this as a fast way to paint the background of any form witha really cool “fading” color (lighter at top to darkerat bottom). To specify base color, pass True/False

Detect Null Or Zero-Length Fields In A Database

This syntax is much faster than using an If.Then.Else construct to detectnull or zero-length fields, and it will ensure that an error will not occur.For strings: Dim sVar As String.sVar

When to Use SendKeys

Use the SendKeys function to exploit the delete functionalityof many grid and spreadsheet controls that have a delete functionality.Use this functionality without writing code to delete each rowif your form

Center Forms Onscreen

I use this procedure to center my forms. With frmParent, the lastloaded form is centered against the parent form. Otherwise, it’scentered against the screen. I always center forms in the