Steve Capistrant
scapistrant at symphonyinfo.com
Fri Sep 5 15:48:28 CDT 2003
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. Regarding this comment.... ------snip begin------- The comment suggests that it is a fully 'articulated' (qualified?) name and spells out what appears to be misconstrued as a string name. What is actually being passed is an object variable by reference which amounts to no more than a long pointer directly to the object in situ --------snip end ------- ...Yes, I meant "qualified". But I don't understand what is wrong with the parameter being sent, and how it might be done differently. Steve Capistrant Symphony Information Services scapistrant at symphonyinfo.com Phone: 612-333-1311 www.symphonyinfo.com 212 3rd Ave N, Ste 404 Minneapolis, MN 55401 -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Henry Simpson Sent: Friday, September 05, 2003 11:56 AM To: accessd at databaseadvisors.com Subject: RE: [AccessD] listbox question Just another comment on the comments pertaining to the parameters and the parameters themselves. First, the function definition accepts a parameter of type 'Control' which, although acceptable, is not as narrow as it could be for the intended purpose. It would be more accurate to define that parameter as type 'ListBox' and that permits intellisense and autocomplete. In a sense, the converse is true of the other parameter; although a byte is the most limited variable one can use to pass one of eight choices and it only uses 8 bits whereas a boolean requires 16. But long gone are the days where the extra 24 bits of a 32 bit long will run an application out of memory. Although an application may benefit in terms of storage and LAN traffic from using a smaller datatype when many records reside in large tables, there is a small overhead when converting the smaller datatype for use by a 32 bit operating system that results in superior performance with a long datatype. As the parameter being passed is a single value, it is more efficient to use a long. The iteration variable is typed as an Integer which is all that is required as the scroll bar of list boxes constrains the number of elements in a list box to exactly the number addressble by an integer but it too is more efficient as a Long. For a mere 16 bits of RAM, a loop that may run up to 64K times is a bit faster and that is a worthwhile tradeoff. The comment suggests that it is a fully 'articulated' (qualified?) name and spells out what appears to be misconstrued as a string name. What is actually being passed is an object variable by reference which amounts to no more than a long pointer directly to the object in situ. I always add an 'invert' option for those cases where you want to select all items except one or two. That way it is easy to click on the exceptions and invert the selections. For this purpose it is useful to declare three Long constants to pass. The third Case (invert) might look like this (if one changes the iteration variable to a Long for the reasons mentioned above, named lngI): Case 3 For lngI = 0 To ctlList.ListCount - 1 ctlList.Selected(lngI) = cltList.Selected(lngI) + 1 Next Hen >From: "Steve Capistrant" <scapistrant at symphonyinfo.com> >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] listbox question >Date: Fri, 5 Sep 2003 08:03:57 -0500 > >Call this public function from any form that has a list box. It can be >used >to SELECT ALL or UNSELECT ALL items. >---------------- > >Public Function FillClearListBox(ctlList As Control, bytAction As Byte) As >Boolean >'Selects or Deselects all items in list box >Arguments: > 'ctlList: the fully articulated name of the listbox (e.g. >Forms!frmMyForm!lstMyList) > 'bytAction: The type of action desired; 1=Select All, 2=Unselect All > >On Error GoTo eh > > Dim intItem As Integer > >'Loop through each item on list and either select or deselect it. > For intItem = 0 To ctlList.ListCount - 1 > Select Case bytAction > Case 1: ctlList.Selected(intItem) = True > Case 2: ctlList.Selected(intItem) = False > End Select > Next > >ex: > Set ctlList = Nothing > Exit Function >eh: > MsgBox Err.Description > GoTo ex >End Function >-------------------------- > >Steve Capistrant >Symphony Information Services >scapistrant at symphonyinfo.com >Phone: 612-333-1311 >www.symphonyinfo.com >212 3rd Ave N, Ste 404 >Minneapolis, MN 55401 > > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Dale Kalsow >Sent: Friday, September 05, 2003 7:41 AM >To: accessd at databaseadvisors.com >Subject: [AccessD] listbox question > > >Ok, I know this should be easy but I am still having a problem with it. >Does any know how to select all of the items in a listbox? > >Thanks! > >Dale _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com