April 16, 1999

Make the Ants March

To implement a quick and easy version of the old “marching ants” line around a control, place two CommandButtons, a Shape, and a Timer control on a form. Then insert this code into the form: Private Sub Command1_Click() StartMarchingAntsEnd SubPrivate Sub Command2_Click() StopMarchingAntsEnd SubPrivate Sub StartMarchingAnts() Timer1.Interval = 200 Timer1.Enabled

Using an Associative Array

An associative array (also called map or dictionary) is an array for which the index does not have to be an integer. An associative array stores pairs of values. One serves as the key and the other is the associated value. The map container is an example of an associated

Retrieving a Control From the Controls Collection With an hWnd

The GetDlgCtrlID API, when passed a valid hWnd, returns a value that directly corresponds to the Index property of the Controls collection: Private Declare Function GetDlgCtrlID Lib “user32” _ (ByVal hWnd As Long) As LongPrivate Sub Form_Load() Dim i As Long On Error Resume Next For i = 0 To

Implement a ListView ItemDoubleClick Event

Double-clicking an icon or file name in Explorer is the standard way of launching an application in Windows. However, if you’re developing an app that uses the ListView control from the Microsoft Windows Common Controls library (COMCTL32.ocx), this functionality is not directly exposed through an event. You have a DoubleClick

Ensure Foolproof Data Entry Times

Asking users to enter time values can often lead to problems formatting what the user enters. I use this piece of code to create a drop-down list of hours, minutes, and AM/PM, which ensures the user specifies the proper time and eliminates problems manipulating the time later in the program.

Use Custom Form Properties

You can easily find out whether your user clicked on OK or on Cancel on a modal dialog. This example also prevents the user from unloading the form, and thereby prevents you from inadvertently reloading the form when you reference the properties of controls on the form: Option ExplicitPrivate mUserHitOK

Keep Your Clustered Index’s Weight Down

In SQL Server 7, a significant change was made to the way nonclustered indexes work when a clustered index exists on a table. In version 6.5, the nonclustered index used the rowid of each row to point back to the data. This meant that when you rebuilt a clustered index

Prevent Browsers From Caching ASP Pages

Whenever you are programming in Active Server Pages, make sure that your browser is set to check for a new page every time. Otherwise, you may not see your latest changes. To ensure that visitors see the latest version of an HTML page that is created on the fly, expire

Stream Unique Identifiers

While attempting to deserialize (or unmarshal) a serialized object instance, you may generate an exception with a message similar to: java.rmi.UnmarshalException: Error unmarshaling return; nested exception is: java.io.InvalidClassException: RMIParm; Local class not compatible: stream classdesc serialVersionUID=9468404698496832181 local class serialVersionUID=7528655624442771181at java.lang.Throwable.(Compiled Code)at java.rmi.UnmarshalException.(Compiled Code)at RMIServer_Stub.getParm(RMIServer_Stub.java:40)at RMIClient.main(RMIClient.java:7) This error occurs as a

No more posts to show