Logo
  NumBox Control
HomePage | Contact | Resume| Client List | EngineeringLinks | Embedded | Forum

NumBox Control
Written by: Michael Karas

This control is a number edit control that permits editing numerical values with range checking and error indications. It also includes an automatic spinner control that permits stepping the numerical value up and down. The edit box image is scaled to the size of the user client space. The font in the edit box is user specified so that it can be customized to a look to suit the host form.

The automatic spinner button controls, which can be turned off if not needed, are setup with a number of nice features. They support timed acceleration of the step rate so that it is easy to click one step but also easy to spin the value up or down rapidly simply by holding down the mouse button. The spinner control button width is user specified and the height is automatically adjusted to the suit the size of the edit box. If the edit control height is too small to permit a usable spinner button size then spinner buttons are placed side by side to allow them to be restored to a useful size. The picture below shows the variation of the spinner button size and layout.



The range checking of the control can be set to operate in an number of ways. The chart below shows the error handling methods supported. The second picture shows how the "Symbolic" method is used to show that the entered number value is out of range.

      


The image below shows the Visual Basic properties box for the NumBox control. Eighteen specialized property settings, all of which are read/write at both design time and run time, provide the ability to customize the control to specific usages.



The following list describes each of these properties:
  • NumBox.BackColor As OLE_COLOR - Specifies the color of the background of the control.


  • NumBox.ForeColor As OLE_COLOR - Specifies the foreground color of the number edit box.


  • NumBox.ErrorColor As OLE_COLOR - Specifies the background color of the number edit box during an error report.


  • NumBox.Font As StdFont - Specifies the Font Selection used in the edit box.


  • NumBox.Alignment As AlignmentConstants - This controls the text alignment used in the edit box. The choices available are:
    1. Left Justify
    2. Right Justify
    3. Center

  • NumBox.BorderStyle As nbBorderStyles - This determines the border style of the box. The choices available are:
    1. Border Style None
    2. Border Style Fixed Single

  • NumBox.Appearance As nbAppearanceStyles - This controls the 2D/3D appearance of the box. The choices available are:
    1. Appearance Style Flat
    2. Appearance Style 3D

  • NumBox.Locked As Boolean - Determines whether the control is locked to editing.


  • NumBox.Enabled As Boolean - Determines whether the control is enabled or not.


  • NumBox.SpinnerWidth As Long - Specifies the spinner button width in twips.


  • NumBox.Min As Double - Minimum value allowed in the control.


  • NumBox.Max As Double - Maximum value allowed in the control.


  • NumBox.Value As Double - Current value in the control.


  • NumBox.Step As Double - Spinner Button Step Size.


  • NumBox.HasSpinner As Boolean - Controls whether the control has spinner buttons.


  • NumBox.ErrorStyle As nbErrorStyles - Determines how the control shows error conditions. The choices available are:
    1. Error Style None
    2. Error Style Quiet
    3. Error Style Symbolic
    4. Error Style Std Text
    5. Error Style User Text

  • NumBox.LowError As Sring - Holds the user style number too low error report string.


  • NumBox.HighError As String - Holds the user style number too high error report string.



The control comes packaged with a simple test application program that permits the number edit control behavior to be manipulated and studied. The picture below shows what this test application looks like:



Click the link below to download the NumBox Edit Control source code and project files that have been packed into a ZIP archive file.

Download NumBox


(Note regarding the download: You may incorporate all or parts of this program into your own project. Keep in mind that you get this code free and as such Carousel Design Solutions has no responsibility to you, your customers, or anyone else regarding the use of this program code. No support or warranty of any kind can be provided. All liability falls upon the user of this code and thus you must judge the suitability of this code to your application and usage).



Email:  mkaras@carousel-design.com
Web Site:  www.carousel-design.com