Home >>VB.Net Programs >VB.Net program to get the smallest value using Math.Min() method
Here, using the Math.Min() method, we can get the smallest value of two numbers and then print the smallest value on the console screen.
Program :
The source code that uses the Math.Min() method to get the smallest value is given below. The program given is compiled and successfully executed.
Example
Module Module1
Sub Main()
Dim X As Decimal = 3.26
Dim Y As Decimal = 6.47
Dim small As Decimal = 0
small = Math.Min(X, Y)
Console.WriteLine("Small value : {0}", small)
End Sub
End Module
Explanation:
We created a Module1 module in the program above that contains the Main() method. We generated two local variables X, Y in the Main() method that are initialized with 3.26 and 6.47 respectively.
small = Math.Min(X, Y) Console.WriteLine("Small value: {0}", small)
Here, we used the Math Class Min() method. Here we get a small value from variable num1 and variable num2 and assign it to the small variable. After that, we printed a small value on the console screen.