Function to return interger with greatest value 
Author Message
 Function to return interger with greatest value

I need to create a pareto chart showing the values of multiple fields in
decending order.  How do I sort a table fields based on the values in the
record.  The query to create the single record is no problem.  Is there a
function that will return the integer with the greatest value in an array?

Thanks in Advance
Don



Wed, 13 Jun 2001 03:00:00 GMT  
 Function to return interger with greatest value
There isn't a built-in function for returning the max value in an
array. The following should work for any array of doubles:

Public Function MaxValue(adblArray() As Double) As Double
  Dim intI As Integer
  Dim dblMax As Double
  dblMax = adblArray(LBound(adblArray))
  For intI = LBound(adblArray) + 1 To UBound(adblArray)
    If dblMax < adblArray(intI) Then dblMax = adblArray(intI)
  Next intI
  MaxValue = dblMax
End Function

If you need to sort an array, there is good algorithm called
dhQuickSort in the VBA Developer's Handbook (Sybex), fully explained.
Or go to http://www.informant.com/mod/modfilearchive.asp and look for
MOD9803RS.zip for a version by Rod Stephens.

 -- Andy

Quote:

>I need to create a pareto chart showing the values of multiple fields in
>decending order.  How do I sort a table fields based on the values in the
>record.  The query to create the single record is no problem.  Is there a
>function that will return the integer with the greatest value in an array?

>Thanks in Advance
>Don




Thu, 14 Jun 2001 03:00:00 GMT  
 Function to return interger with greatest value
Andy,

Thanks, I'll check that our.  It seems like it would work

Don


Quote:
>There isn't a built-in function for returning the max value in an
>array. The following should work for any array of doubles:

>Public Function MaxValue(adblArray() As Double) As Double
>  Dim intI As Integer
>  Dim dblMax As Double
>  dblMax = adblArray(LBound(adblArray))
>  For intI = LBound(adblArray) + 1 To UBound(adblArray)
>    If dblMax < adblArray(intI) Then dblMax = adblArray(intI)
>  Next intI
>  MaxValue = dblMax
>End Function

>If you need to sort an array, there is good algorithm called
>dhQuickSort in the VBA Developer's Handbook (Sybex), fully explained.
>Or go to http://www.informant.com/mod/modfilearchive.asp and look for
>MOD9803RS.zip for a version by Rod Stephens.

> -- Andy


>>I need to create a pareto chart showing the values of multiple fields in
>>decending order.  How do I sort a table fields based on the values in the
>>record.  The query to create the single record is no problem.  Is there a
>>function that will return the integer with the greatest value in an array?

>>Thanks in Advance
>>Don




Thu, 14 Jun 2001 03:00:00 GMT  
 Function to return interger with greatest value
Don --
    I assume that your records consist of some sort of ID (date, machine,
group, whatever) and then a tally of the incidence of a list of problems.
You might want to consider creating a new table each of which contains the
ID, a problem label or code, and a tally.  Then you can just sum and sort
this table.  The advantage of this organization is that it can handle
changed problem lists more easily.
-- Roger
Quote:

>I need to create a pareto chart showing the values of multiple fields in
>decending order.



Fri, 15 Jun 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. problem using component with asp page -- result of function not returned, instead original value returned

2. Form as Dialog returning value - function style

3. Returning more than one value from a function

4. return a value from a function

5. Returning values from Functions

6. Function to Return String Value of Date

7. Function that returns more than one value

8. Returning value from functions

9. function return value can't be object?

10. VB.NET Function Return Values

11. why the round function return different value?

12. The Proper Was to If a Functions Return Value

 

 
Powered by phpBB® Forum Software