A range validation Edit control


How to Help Your Business Become an AI Early Adopter

Download Source Code and Example

In a project that I am working with about 6 people, we were using spin controls and edit controls to allow the operator to change certain values. We decided we needed one way to handle invalid data typed in the edit control by the operator. The best solution we came up with was to sub-class CEdit, and validate the operators key-strokes.

  1. Ensure that the edit control has the number only style set to TRUE.
  2. Then you need to include the "CRangeEdit.h" in your dialog definition file, and declare CRangeEdit member variables for each edit control that you need to check the range of an operators input.
  3. Then you must set the range the CRangeEdit will accept from the operator, using the CRangeEdit::SetRange() method. The CRangeEdit will default to 0-100 range.
  4. Set the default contents of the control using CWnd::SetWindowText().

You should be ready to go!

Last updated: 29 April 1998


  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Cloud has the potential to offer many benefits that can enable great success within your business. However, there are still many myths floating around about backing up to the cloud. In this eBook, you'll discover the truth about five of the most common cloud myths, including myths about security, maintaining regulatory compliance and more. Get to the truth, so you can backup to the cloud with confidence.

  • Why use NoSQL? Innovative companies like AT&T, GE, and PayPal have successfully transitioned from relational to NoSQL for their critical web, mobile, and IoT applications. By understanding where to introduce NoSQL, how to model and access the data, and how to manage and monitor a distributed database, you can do the same. This white paper explains the need for non-relational databases, describes advantages of NoSQL, and clarifies the important difference between SQL and NoSQL databases. We walk you …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date