View Full Version : Min(), Max() in VB
Apparently there is no Min or Max function in VB, a programmer needs to do the following
Min --> IFF(a<b,a,b) Max --> IFF(a>b,a,b)
Clearly I can build my own but I find it hard to believe a built in function doesn't exist.
urysohn
06-04-2002, 01:17 PM
If you are using VBA (Visual Basic within Excel, for example) you can use many worksheet functions, including Min and Max. Just use:
answer = Application.Min(myRange)
If you are not using the Excel version, I don't have much of a reply. I would create a public function for Max and Min and either place them in a publically avaialable area or have them handy to copy/paste when needed.
Ben Kenobi
06-04-2002, 01:56 PM
The IFF makes me think you're programming in Access, and I have more than once missed MIN() and MAX() there myself. For Urysohn's version to work in Access, you'd need to link in the Excel library, which is probably more painful than defining the functions yourself.
Cho Da
06-04-2002, 01:59 PM
in Acess you need to use IIF not IFF.
Ben Kenobi
06-04-2002, 02:36 PM
:oops:
Thrashard
06-04-2002, 02:44 PM
How about domain Agg Functions?
DMAX and DMIN? They come in handy.....
I'm programming in VB not in Excel or Access. Yes, it's IIF I made a typo.
I'm not familiar w/ agg functions, can you point me in the right direction.
Thanks
Apparently there is no Min or Max function in VB, a programmer needs to do the following
Min --> IFF(a<b,a,b) Max --> IFF(a>b,a,b)
Clearly I can build my own but I find it hard to believe a built in function doesn't exist.
You don't need a Min or a Max function in VB. If you did, the folks at Microsoft would have built them in.
Arlie_Proctor
06-07-2002, 10:05 AM
Huki:
Not quite. If min and max were truly needed, Microsoft would have offered a developers' toolkit (at additional cost) that included them :swear:
vBulletin® v3.7.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.