Mat - Trovare Il Valore Minimo E Massimo Di Un'array



Visual # Questa funzione, restituisce il valore massimo trovato all'interno di un'array
di dati, passatogli come argomento
Function ValoreMassimo(Valori_Ary as variant) as long
Dim Confronto as long
Dim Vr_Max as long
Dim a as integer
if isarray(Valori_Ary) then
if UBound(Valore_Ary) = -1 then
Vr_Max = Null
else
Vr_Max = Valori_Ary(UBound(Valori_Ary))
for a = LBound(Valori_Ary) to UBound(Valori_Ary)
Confronto Valori_Ary(a)
if Confronto > Vr_Max Then '* Vedi nota in fondo
Vr_Max = Confronto
end if
next a
end if
ValoreMassimo = Vr_Max
else
ValoreMassimo =Null
end if
End Function

Sostituendo l'operatore di confronto nell'interazione centrale della funzione
sopradescritta e' possibile calcolare il valore minimo.
if Confronto < Vr_Min then
Vr_Min = Confronto
end if

(mattrovareilvaloreminimoemassimodiun'array.html)- by Paolo Puglisi - Modifica del 25/3/2019