Not Too Small or Too Big - July 2002

Some years ago I wrote two functions called 'NotTooSmall' and 'NotTooBig'. I use the functions all the time. I recently used the functions in an application I'm developing and decided to enhance them, added function 'NotTooSmallBig' and decided to make these functions the July 2002 tip-of-the-month.

The Demo Program

I created a VB 6 demo program to show how to use the functions. The demo program screen:

Change the values then try resizing the form.
Use the buttons to set the form to the indicated size.

Using the Functions

Function, Arguments Description Sample
NotTooSmallBig(vntValue, _
    vntMin, vntMax)
Make sure it falls between Min and Max. iMyNumber = NotTooSmallBig(iMyNumber, 300, 1000)
NotTooSmall(vntValue, vntMin) Make sure it is larger then Min. lWidth = NotTooSmall(lWidth, 500)
NotTooBig(vntValue, vntMax) Make sure it is smaller than Max. lHeight = NotTooBig(lHeight, Screen.Height)

Use Subclassing to Restrict a Form's Size

Although I've used the functions to restrict the size of the demo form it is not the 'best way' to restrict a form's size. Click here to review the June 2001 tip: 'Restrict a Form's Size and a Moved Event'. That tip uses 'subclassing' to restrict a form's size and to provide a 'Moved' event - an event sorely needed in VB6 - and now provided in VB.Net.

The Demo Program Uses These Modules

Module - Click for More Info Description Used in the Demo To
modNotTooSmallBig.bas Contains functions described in this tip. Add it to your application to use the functions.
modConnectToWebSite.bas Connect to a web site Show this info when Help/Info is selected from the demo.
modInfoAbout.bas Info and about help. Provide help via the web and 'about' info.

Download VB 6 Source Code

Click here to download the VB 6 source code [7k]

Previous Tip   Tip Index   Next Tip   First Tip


Updated 2002/08/02