O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Min Function

Class

System.Math

Syntax

Math.Min(val1, val2)
val1, val2 (required; any numeric)

A numeric data type or expression

Return Value

Returns the minimum of val1 and val2 in the widest data type of the two numbers

Description

Returns the minimum of val1 and val2, in the same data type as the numbers. See Section for more detail.

Rules at a Glance

  • If the two arguments do not have the same data type, then the narrower data type is cast to the wider type. For instance, the code fragment:

    Dim x As Integer = 5
    Dim y As Double = 454.8
    MsgBox(Math.Min(x, y))

    displays 454.8 without error. The datatype returned by the function in this instance is a Double.

  • This is a Shared member, so it can be used without creating any objects.

VB.NET/VB 6 Differences

The Min function is new to the .NET Framework.

See Also

Max Function

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required