December 30, 2000

Clear a MaskEditBox control without raising error

You can’t clear the contents of a MaskEdBox control by setting the Text property to a null string if the MaskEdBox’s Mask property contains delimiter. In fact, you must include those separators in the value you assign to the Text property, otherwise you get Error 380 – Invalid property value.A

Hide and show the mouse cursor

At times you may want to temporarily hide the mouse cursor, for example in order to reduce flickering. To do so you just need the ShowCursor API function: Private Declare Function ShowCursor Lib “user32” (ByVal bShow As Long) As Long’ hide the mouseShowCursor False’ do whatever you need to do’

Avoid beeps on forms without a default button

If a form contains one CommandButton control whose Default property is set to True, the Enter key activates the CommandButton. If the form doesn’t contain any default CommandButton control, however, pressing the Enter key when the focus is inside a TextBox control (and a few other controls as well) results

Change a CheckBox or OptionButton style at runtime

Visual Basic doesn’t let you change the Style property of a CheckBox or an OptionButton control at runtime. However, you can easily do it by manipulating the control’s style bit, with the SetWindowLong API function. Here’s a routine that does the trick: Private Declare Function GetWindowLong Lib “user32” Alias “GetWindowLongA”

Provide better visual feedback for disabled TextBox and ComboBox controls

When you disable a control, VB grays its contents. However, often this action goes unnoticed by the end users. Here’s a routine that changes the control’s BackColor property in addition to changing its Enabled property: ‘ enable/disable a textbox or a combobox’ (also changes its background)Sub EnableTextBox(tb As Control, ByVal