borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (How to Round a number ?)Next Topic (db data -->vb in one by one data (using text botton in vb)) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Is there any MAX function in VB6 ?
Poster Message
iliekater
Level: Master

Registered: 04-02-2005
Posts: 122

icon Is there any MAX function in VB6 ?

I need a MAX function so that I can easily pick the maximum value from lots of number . I am sure there has to be one , every language has one (even VBA has it) .

25-02-2007 at 10:22 PM
View Profile Send Email to User Show All Posts | Quote Reply
TJ_01
Level: VB Lord


Registered: 24-08-2005
Posts: 320
icon Re: Is there any MAX function in VB6 ?

Im not sure if i satisfy you with my answers. MAX function can be use in SQL Query for getting the latest or maximum value in the database. If you want to get max value or last value in vb, you can use Left function or right function and substring.

____________________________
Im JAMES  

08-03-2007 at 04:51 AM
View Profile Send Email to User Show All Posts | Quote Reply
iliekater
Level: Master

Registered: 04-02-2005
Posts: 122
icon Re: Is there any MAX function in VB6 ?

I am just interesting in numbers . You see , there are times when some things have to be calculated with many matematical formulas and , at the end , the chosen result is the maximum of all previusly resulted numbers . Up to now I simply use code to select the code , but this is getting annoying . In case there isn't any MAXIMUM function , it is a shame for VB . All languages have this function ; even the old Fortran I used some years ago , had it .

[Edited by iliekater on 22-03-2007 at 02:22 PM GMT]

22-03-2007 at 10:20 PM
View Profile Send Email to User Show All Posts | Quote Reply
yronium
Level: Moderator


Registered: 14-04-2002
Posts: 907
icon Re: Is there any MAX function in VB6 ?

Well, it seems that my last post here has been lost, so I'll reply again.

quote:
iliekater wrote:...every language has one (even VBA has it)...
Are you sure of it? I typed "Max(" into Excel's VBA editor, but no IntelliSense suggestion appeared. So I highlighted the word "Max" and pressed F1, but I get a message of unknown keyword. I did the same into MSWord VBA Editor getting the same result, and so into MSAccess and Corel Draw VBA editors. So what VBA are you referring to?

Basically, the Max function is not a programming function. Is a typical database aggregation function, such as Sum, Count, Min and Average functions, and all are used when retrieving records. They are SQL functions, and if you have found it into MSAccess it is only because Access provides some SQL features into its interface in order to manage records, but this doesn't mean that it is a VBA function. It's like you would expect some kind of Select, Update or Insert function among VB functions. In fact, the bare VB is not capable itself to interface with databases, nor VBA is: they both need some external tools to do it, like ADO, DAO, RDO, JRO, and so on. This is the reason why Word, Excel, PowerPoint and other VBA-provided aplications can't manage records: neither Access could natively do it, without ADO (... you know that Access internally uses ADO to manage the dbs, didn't you?...). And even these powerful tools, though they extablish a connection with a db, can't always provide aggregation functions - to verify it, try executing a recordcount on a server side recordset.

Anyway, there's no need to have a Max function into VB, as is not hard to implement your own. Only, you got to use a loop, but there are many tricks to speed it up. And if you loop thru a Collection instead than an array, you can do it as fast as hell. No wonder if some math-oriented languages, like Fortran, implement it, as it can be useful with numbers, but there's really no need of such this function as native. Mind that VB hasn't got any root operator, too, but this doesn't mean roots are not avaliable in VB.

Hope it helps (and hope this time my topic won't be lost).

[Edited by yronium on 23-03-2007 at 11:06 AM GMT]

____________________________
Real Programmer can count up to 1024 on his fingers
23-03-2007 at 10:05 AM
View Profile Send Email to User Show All Posts | Quote Reply
iliekater
Level: Master

Registered: 04-02-2005
Posts: 122
icon Re: Is there any MAX function in VB6 ?

Thanks for your reply , Yronium . You gave me an idea : I will create a public function to do my job !
However , I don't want to use it for data bases , I only want to use it for arithmetic values .
And , yes , you are right . There is no MAX function in VBA ... I admit I never verified it . I just read in a pdf book that the VBA equivalent for the MAX function in Visual LISP (for AutoCAD) is the MAX function (which as I said actually does not exist) . In order to prove it I have uploaded that file here :
http://rapidshare.com/files/22465091/4015c97Book.zip.html
Just go to page 36 to see for yourself !

23-03-2007 at 10:32 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Is there any MAX function in VB6 ?
Previous Topic (How to Round a number ?)Next Topic (db data -->vb in one by one data (using text botton in vb)) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder