[AccessD] highest value of 4 variables - urgent

Michael R Mattys mmattys at rochester.rr.com
Sun Nov 4 17:16:40 CST 2007


Oh, Sorry.

Sub QuickSort(A() As Integer, ByVal Low As Integer, ByVal Hi As Integer)
'
' Very fast sort: n Log n comparisons
'
' Calling convention:
'   Redim A(1 To 20) as Integer
'   QuickSort A(), 1, 20
'
Dim MidValue As Integer, i As Integer, j As Integer, Temp As Integer
  If Hi <= Low Then Exit Sub
  MidValue = A((Low + Hi) \ 2)
  i = Low
  j = Hi
  Do While i <= j
    If A(i) >= MidValue And A(j) <= MidValue Then
      Temp = A(i)
      A(i) = A(j)
      A(j) = Temp
      i = i + 1
      j = j - 1
    Else
      If A(i) < MidValue Then i = i + 1
      If A(j) > MidValue Then j = j - 1
    End If
  Loop
  QuickSort A(), Low, j
  QuickSort A(), i, Hi
End Sub

Function TestQuickSort()
   ReDim A(1 To 8) As Integer
   A(1) = 64: A(2) = 16: A(3) = 8: A(4) = 32: A(5) = 40: A(6) = 48: A(7) = 
24: A(8) = 56
   QuickSort A(), 1, 8
   Debug.Print "Min: " & A(1) & " and Max:" & A(8)
End Function

Michael R. Mattys
MapPoint & Access Dev
www.mattysconsulting.com

----- Original Message ----- 
From: "jwcolby" <jwcolby at colbyconsulting.com>
To: "'Access Developers discussion and problem solving'" 
<accessd at databaseadvisors.com>
Sent: Sunday, November 04, 2007 12:53 PM
Subject: Re: [AccessD] highest value of 4 variables - urgent


> LOL, the least you could have done is dig up the quicksort.
>
>
> John W. Colby
> Colby Consulting
> www.ColbyConsulting.com
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Michael R 
> Mattys
> Sent: Saturday, November 03, 2007 7:58 PM
> To: Access Developers discussion and problem solving
> Subject: Re: [AccessD] highest value of 4 variables - urgent
>
> Remember this? (Just kidding, but it is from NeatCode.mdb)
>
> Sub ShellSortArray(A() As Variant)
> Dim i As Long, j As Long
> Dim Low As Long, Hi As Long
> Dim PushPop As Variant
>   Low = LBound(A)
>   Hi = UBound(A)
>   j = (Hi - Low + 1) \ 2
>   Do While j > 0
>     For i = Low To Hi - j
>      If A(i) > A(i + j) Then
>         PushPop = A(i)
>         A(i) = A(i + j)
>         A(i + j) = PushPop
>      End If
>     Next i
>     For i = Hi - j To Low Step -1
>      If A(i) > A(i + j) Then
>         PushPop = A(i)
>         A(i) = A(i + j)
>         A(i + j) = PushPop
>      End If
>     Next i
>     j = j \ 2
>   Loop
> End Sub
>
> Function TestShellSortArray()
>    Dim vA() As Variant
>    Dim i As Long
>    vA = Array(64, 16, 8, 32, 40, 48, 24, 56)
>    ShellSortArray vA()
>    For i = LBound(vA()) To UBound(vA())
>        Debug.Print vA(i)
>    Next
> End Function
>
> Michael R. Mattys
> MapPoint & Access Dev
> www.mattysconsulting.com
>
> ----- Original Message -----
> From: "Kath Pelletti" <kp at sdsonline.net>
> To: "Access Developers discussion and problem solving"
> <accessd at databaseadvisors.com>
> Sent: Saturday, November 03, 2007 7:35 PM
> Subject: Re: [AccessD] highest value of 4 variables - urgent
>
>
>> That's where I am with it too Rocky - until I get another solution I will
>> go
>> with this.....(but I'm sure there will be something that we both can't
>> remember?)
>>
>> Ta
>> ----- Original Message ----- 
>> From: "Rocky Smolin at Beach Access Software" <rockysmolin at bchacc.com>
>> To: "'Access Developers discussion and problem solving'"
>> <accessd at databaseadvisors.com>
>> Sent: Sunday, November 04, 2007 10:29 AM
>> Subject: Re: [AccessD] highest value of 4 variables - urgent
>>
>>
>>> Brute Force?
>>>
>>> Function GetHigh as Variant
>>>
>>> GetHigh = var1
>>> If var2 > GetHigh Then GetHigh = var2
>>> If var3 > GetHigh Then GetHigh = var3
>>> If var4 > GetHigh Then GetHigh = var4
>>>
>>> End Function
>>>
>>> I'm sure there's a more elegant way...
>>>
>>> Rocky
>>>
>>>
>>>
>>>
>>>
>>> -----Original Message-----
>>> From: accessd-bounces at databaseadvisors.com
>>> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Kath Pelletti
>>> Sent: Saturday, November 03, 2007 3:57 PM
>>> To: Access D Normal List
>>> Subject: [AccessD] highest value of 4 variables - urgent
>>>
>>> maybe i am having a vague moment - but what function can I use to get 
>>> the
>>> highest value of 4 variables, eg:
>>>
>>>
>>> eg. I want to know x where x is the highest of (var1, var2, var3, var4)
>>>
>>> ta
>>> ______________________________________
>>> Kath Pelletti
>>> --
>>> AccessD mailing list
>>> AccessD at databaseadvisors.com
>>> http://databaseadvisors.com/mailman/listinfo/accessd
>>> Website: http://www.databaseadvisors.com
>>>
>>> No virus found in this incoming message.
>>> Checked by AVG Free Edition.
>>> Version: 7.5.503 / Virus Database: 269.15.19/1106 - Release Date:
>>> 11/2/2007
>>> 9:46 PM
>>>
>>>
>>> -- 
>>> AccessD mailing list
>>> AccessD at databaseadvisors.com
>>> http://databaseadvisors.com/mailman/listinfo/accessd
>>> Website: http://www.databaseadvisors.com
>>>
>>
>>
>> -- 
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com 




More information about the AccessD mailing list