[dba-VB] Just a Christmas quickie Using Not Instead of = False

jwcolby jwcolby at colbyconsulting.com
Thu Dec 24 10:14:22 CST 2009


Paul,

Perhaps better would be:

if MyRecordset.BOF and MyRecordset.EOF then
	msgbox "Empty"
else
	do stuff here
endif

It is easier to read the true than the nots, especially when there is more than one.  Either one 
works.  If this is in a tight loop and speed matters, then the NOT might cause a very slight 
slowdown as it is two extra boolean operators.  OTOH the compiler might just pick it up and rewrite 
it to my syntax anyway.

John W. Colby
www.ColbyConsulting.com


Paul Hartland wrote:
> To all,
> 
> I use a lot of recordsets, and to detect they actually contain something I
> have always used the following:
> 
> If myrecordset.bof=false and myrecordset.eof=false then
>     do my stuff here
> Else
>     msgbox "empty"
> End If
> 
> However my project manager prefers:
>  If not myrecordset.bof and not myrecordset.eof then
>     do my stuff here
> Else
>     msgbox "empty"
> End If
> 
> Is there actually a prefered way, or is one quicker than the other, or is
> there an even better way to do this ?
> 
> Thanks in advance for any comments, and a very merry christmas & happy new
> year to everyone.
> 



More information about the dba-VB mailing list