October 30, 1999

Enable and Disable all or part of a scrollbar

The new FlatScrollbar controls expose the ability to selectively disable their arrows. This is useful, for example, when the thumb indicator is at its minimum or maximum: Private Sub FlatScrollBar1_Change() If FlatScrollBar1.Value = FlatScrollBar1.Min Then FlatScrollBar1.Arrows = cc2RightDown ElseIf FlatScrollBar1.Value = FlatScrollBar1.Max Then FlatScrollBar1.Arrows = cc2LeftUp Else FlatScrollBar1.Arrows = cc2Both

Hide and Show a control’s scrollbars

Most VB controls don’t let you determine whether they should display a scrollbar or not. For example, a VB ListBox control displays a vertical scrollbar only when the number of its items is larger than the number of visible items. If you want to directly control individual scrollbars, you can

Create colorful Command Buttons

The VB CommandButton control supports neither the ForeColor nor the BackColor properties. If you want to create colorful buttons without resorting to 3rd party controls, you can use an OptionButton control with the Style property set to 1-Graphical. Such OptionButton controls appear to be very similar to regular CommandButton controls,

Make a Checkbox control read-only

By default, VB’s CheckBox controls automatically toggle their Value property when the user clicks on them. This is usually the desired behavior, but at times you may want to be able to change their value only programmatically. Unfortunately, you can’t achieve this result by simply setting the CheckBox control’s Enabled

Change the width of the dropdown portion of a ComboBox

The ComboBox control doesn’t expose any property that lets you to control the width of its list area, but this can be easily accomplished by sending it the CB_SETDROPPEDWIDTH message, and passing the new length in pixel in wParam: Private Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal _ hwnd

Implement a MaxLength property for the ComboBox control

Unlike the TextBox control, the ComboBox control doesn’t expose any MaxLength property, so you have no means of limiting the numbers of characters typed by the end user in the edit area. However you can set this value by sending a CB_LIMITTEXT message to the control, passing the maximum number

Debug Print in an EXE

Contrary to common belief, Debug.Print statements are not always removed from an executable. This behavior can be demonstrated easily. Open a new project, place a single CommandButton on the default form, and add this code: Public Function DebugTime() MsgBox “Caught!”End FunctionPrivate Sub Command1_Click() Debug.Print DebugTimeEnd Sub Compile the program to

Streamline Math in VBA

It’s possible to streamline some calculation procedures in Excel and add calculation capabilities that don’t exist in Word. Unfortunately, most textbooks on VB for Office 97 are focused on nonmathematical features such as text formatting or graphic displays. This situation creates a significant challenge for those who want to use

Using Efficient Remote Interface Design

Because server/client round-trips are inherently inefficient, you should try to eliminate the need for excessive round-trips. When you design a class or a user-defined interface, you should never expose three public methods or properties when a single method can accomplish the same. If your class exposes two public properties, a

No more posts to show