
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.
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
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
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.
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
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
Although it is undocumented and illogical, using IIF requires you todistribute MSAFINX.DLL with your program.
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
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
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
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
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 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.
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,
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
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
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
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,
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
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.
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
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.
If you’re getting GPFs and you aren’t sure if the cause is your customDLL or VB, write a BAS file stub that simulates your DLL. If the GPFs persist,its not
If you ever need to disable all the controls on a form you can loopthrough the control array and set each Enabled property to Falsewith this code: Sub cmdArray_Click ()
The CBFindString()procedure searches for a string in a combo box byusing the SendMessage() API function to find a specific entry in the list.This is much more efficient than searching using
For debugging or whenever you want to copy code from one project toanother, it would be very easy if you could have two instances of VB runningat the same time.
Use the Len() function to check for an empty string rather than the”” or “=” operators. For instance: If sName “” Then … End If This is functionally the same,
Every control has an implicit “value” property. For textboxes it is the Text property. For Labels it is Caption: lblZip.Caption = “Zip Code” You do not need to reference this
If you have a large app, consider breaking it down into smaller apps.Use one main EXE that calls the others and DDE to provide communication.When a sub-app opens, open a
There is a very simple trick you can perform with labels and text boxesthat will help users who like to use the keyboard instead of the mouse.Notice the underlines in
To set a form to be always on top, use the subroutine listed here.Pass it the hWnd property of the form you want to float. The OnTop parameteris used to