NumberBox (ActiveX Control)

This control is mostly a textbox, but it is designed for use with numeric values. In addition to exposing all the standard textbox members it also provides a Value property which can be used for the setting or reading of a numeric value. Display and entry can be set to be in Hexadecimal or Decimal base. Validity can be constrained to upper and lower limits. Visual indication of validity (different colour backgrounds) is available, and a .Validate function (returning True or False) provided for convenience. An optional spin button (made from standard buttons - does not require common controls OCX) can be displayed which allows the user to easily increase or decrease the value in the NumberBox by a specified step.

A Style property is exposed which lets you select whether the NumberBox should accept entry in Hexadecimal or Decimal. The Value property will still work in the same way for either mode, returning the actual numeric value entered. So if the NumberBox is in Hex mode and the user enters 10, the Value property return 16. If the Style property is then changed to Decimal (LongInteger) the NumberBox changes to display 16, and the Value property remains as 16.

Whenever the user changes the text in the NumberBox the validity of what they have entered is checked. There are three possible states, either the NumberBox is blank, contains a valid number (or Hex String, depending on the Style property), or contains an invalid number. If the ValueLimited property is True then validity includes being between or equal to the UpperLimit and LowerLimit properties, otherwise any numerical value is considered value. The three colour properties ValidColour, EmptyColour and InvalidColour define the colours which should be used as the NumberBox background colour to indicate the current validity of what has been entered. This behaviour can be switched off by setting the UseColours property to false, in which case the BackColour property is always used as the background colour. Validity can always be found by calling the Validate method, which returns true if the current entry is valid, or false otherwise.

If the UseButtons property is True then Spin Buttons will appear by the side of the text entry area. These can either stretch vertically to fill the full height of the control, or remain at the standard size at the top right corner. This behaviour is set by the StretchButtons property. The user can also use the Up and Down arrow keys as an alternative to clicking on the buttons. The value is adjusted by an amount set in the ButtonStep property for each click. If the NumberBox is ValueLimited then when clicking the button would bring the value outside the valid region it becomes disabled. The Spin Buttons can not recieve the focus under any circumstances, so it is possible to tab past the NumberBox control with one Tab press. Events are exposed to notify when these buttons are clicked.

All standard textbox members are exposed except for MultiLine (as this does not make a lot of sense for this control), DDE properties and Data Binding properties.

Files available for Download:

Description File Name Size Version
avNumberBox Control "avNumberBox.ocx" 30.9K 1.00
Property Page Support (not needed for Visual Basic) "Msstkprp.dll" 37.2K 6.00.8169
Visual Basic 6 Runtimes (not needed for VB 6) "Vbrun60.exe" 973K SP3

Please email me if you wish to comment on this program, or to send in any bug reports or suggestions.