
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.
Occasionally, you may want to use on your form a beveled panel that allows you to designate a background bitmap. Rather than use a third-party control, you can use the
To prevent users from typing spaces in a text box, include this code in the KeyPress event of the text box: Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 32
In general, stored Access queries are faster than embedded SQL in your VB application. It can be a great benefit to be able to send parameters to the query directly
You can quickly find the name of the Windows or the Windows System directory. Just pass “WindowsDirectory” or “WindowsSystemDirectory” into this function: Declare Function wu_GetWindows_ Directory Lib “Kernel” Alias _
Use this code to quickly determine whether Microsoft Mail is currently running: Declare Function GetModuleHandle Lib _ “Kernel” (ByVal lpModuleName As String) As IntegerFunction IsMicrosoftMailRunning ()On Error GoTo IsMicrosoftMailRunning_ErrIsMicrosoftMailRunning =
If you get the error “User-defined type not defined” on a line where you are declaring a database, go to Tools, then go to References, and select the appropriate DAO
Sometimes you need to change the size of controls by changing the size of a container. For example, try this: Private Sub Form_Resize() Picture1.Align = vbAlignLeft Picture1.Align = vbAlignTopEnd Sub
While working on VB projects with associated Jet databases, I found that I was creating a lot of individual handling functions for reading, writing, and validating data. It was hard
When a user presses the Cancel button, the control that previously had focus triggers its LostFocus event, which is where many programs do their validity checking. If the input wasn’t
Rather than using Visual Basic’s line and shape objects when drawing complex graphic backgrounds on forms, use the MS Draw applet included with most Microsoft products to draw a Windows
One problem that occurs frequently is taking the menu structure from one form and placing it in another. Although my method of dealing with this dilemma requires a little effort,
Suppose you have two list boxes side by side-one to display the name of a person, the other to display his or her e-mail address. If the boxes contain several
I have seen many posters in the VB newsgroups that say they have received an ODBC error message such as 3146, but can’t figure out why they got the message.
Sometimes it is useful to set a cursor to determine control when a form is loading-after the form is done loading, the cursor stays on the control you have ordered:
To synchronously shell an application from a 16-bit VB application, some people write code like this: Const HINSTANCE_ERROR% = 32Dim hInstChild As Integer’Shell program, if Shell worked, enter loophInstChild =
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
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
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
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
In reference to “Unregister a DLL with the Right Mouse Button in Win95” [VBPJ March 1996, page 72], I would like to suggest a tip that is much easier to
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,
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
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
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
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.