[AccessD] Small data types (was: listbox question)

Henry Simpson hsimpson88 at hotmail.com
Sat Sep 6 15:09:03 CDT 2003


This is one of the reasons I suggested using user defined constants for the 
possible parameter values.  I also believe that it is wise to include range 
checking in any procedure that accepts a restricted range of values in the 
parameters.  The Select Case can then select against each constant and 
provide a Case Else for an out of range value.  In the case of month and day 
values, it is generally wise to check with IsDate() because range checking 
requires too many rules with variable length months and leap years.

If you look at the 16 bit API functions, they generally return 16 bit values 
and 32 bit API functions generally return 32 bit values and rely on 
enumerated constants for interpretation of return values no matter whether 
they are boolean, fall within byte, integer or long range.  When it comes to 
object variables, it is best to be as precise as your binding permits 
because the type checking will ensure that the error is returned from the 
procedure that caused the error making any logging scheme return more useful 
information.  In the example this thread referred to, there are many 
variables of type 'Control' that to not have a collection of selected items 
that may be accidentally passed.  If anything but a ListBox is passed by 
reference, the error is raised in the example function.  If the parameter 
were dimensioned as a ListBox, then the error would be invoked in the caller 
should an incorrect variable type be passed.  When you have a general 
procedure that may be called from hundreds of different places, it is far 
more useful to identify the source of the error in the caller.  If you have 
access to the call stack, it is easy enough to trace the origin of the 
error, but once you are dealing with a deployed MDE file, it is far more 
useful to have the error log point to the caller.

Hen

>From: Gustav Brock <gustav at cactus.dk>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>Subject: Re: [AccessD] Small data types (was: listbox question)
>Date: Sat, 6 Sep 2003 10:54:30 +0200
>
>Hi Steve
>
>Byte values are nice when you wish to prevent negative or "large"
>integer values, say month and day values, passed to a function.
>
>However, one has to be careful when doing arithmetics with these as
>any interim calculated value which will result in a negative value
>will cause the function to fail.
>
>/gustav
>
>
> > Henry, you make my head hurt.
>
> > But seriously, thanks for the comments; we've got hundreds of functions 
>in
> > which we consciously chose the smaller data type in an effort to be more
> > efficient, and it sounds like that is just an example of good intentions
> > with opposite results.

_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail



More information about the AccessD mailing list