User Tools

Site Tools


vba:functions:least

[VBA] least()

Gibt den Kleinsten aus einer unbestimmten Menge von Werten zurück.

Version 1.0.0 -

Beispiele

?least(4, 5, 13, 7)
 4 
?least("Hans", "Thomas", "Marcel")
Hans
?least(Null, 1, -1)
-1 

Code

udf_least.bas
Attribute VB_Name = "udf_least"
'-------------------------------------------------------------------------------
'File         : udf_least.bas
'               Copyright mpl by ERB software
'               All rights reserved
'               http://wiki.yaslaw.info/dokuwiki/doku.php/vba/functions/least
'Environment  : VBA 2010 +
'Version      : 1.0.0
'Name         : strSplit
'Author       : Stefan Erb (ERS)
''-------------------------------------------------------------------------------
Option Explicit
 
'/**
' * Gibt den Kleinsten aus einer unbestimmten Menge von Werten zurück
' * @param  Keine Objekte
' * @return Grösster Wert
' * @example least("Hallo Welt", 42, "Mister-X") -> 42
'*/
Public Function least(ParamArray iItems() As Variant) As Variant
    least = iItems(LBound(iItems))
    Dim item As Variant: For Each item In iItems
        If NZ(item) < NZ(least) Then least = item
    Next item
End Function
 
 
 

Discussion

Enter your comment. Wiki syntax is allowed:
If you can't read the letters on the image, download this .wav file to get them read to you.
 
vba/functions/least.txt · Last modified: 31.08.2015 08:56:35 by yaslaw