Ref: Notes/Domino 4 and 5 Forum
Function MaxIndex( inputArray As Variant ) As Integer
' ----------------------------------------------------------------------------------------------------------------------------------
' MaxIndex( ) written by Trent Overton - toverton@wgcinc.com
' ----------------------------------------------------------------------------------------------------------------------------------
' Description
' Finds the maximum value in an array and returns the index to that element.
' Note: Array must contain values which can be compared with standard operators.
'
' Parameters
' inputArray - array passed as variant data type
'
' Return value
' integer representing index to largest element in array.
' error conditions cause return value to be -1
'
' ----------------------------------------------------------------------------------------------------------------------------------
On Error Goto ErrorHandler
Dim rc As Integer
rc = -1
If Isarray( inputArray ) Then
Dim index As Integer
For index = Lbound( inputArray ) To Ubound( inputArray )
If rc = -1 Then
rc = index
Elseif inputArray( index ) > inputArray( rc ) Then
rc = index
End If
Next
End If
MaxIndex = rc
ErrorHandler:
rc = -1
Resume Next
End Function
quarta-feira, 8 de fevereiro de 2012
@Min and @Max on LotusScript lists
Ref: Notes/Domino 6 and 7 Forum
********** MAX **********
Function Max(numList List As Integer) As Integer
Dim iMax As Integer
iMax = -32768
Forall num In NumList
If(num > iMax) Then iMax = num
End Forall
Max = iMax
End Function
' ********** MIN **********
Function Min(numList List As Integer) As Integer
Dim iMin As Integer
iMin = 32767
Forall num In NumList
If(num > iMin) Then iMin = num
End Forall
Min = iMin
End Function
********** MAX **********
Function Max(numList List As Integer) As Integer
Dim iMax As Integer
iMax = -32768
Forall num In NumList
If(num > iMax) Then iMax = num
End Forall
Max = iMax
End Function
' ********** MIN **********
Function Min(numList List As Integer) As Integer
Dim iMin As Integer
iMin = 32767
Forall num In NumList
If(num > iMin) Then iMin = num
End Forall
Min = iMin
End Function
Assinar:
Postagens (Atom)