Home »
VB.Net »
VB.Net Programs
VB.Net program to get the smallest value using Math.Min() method
By Nidhi Last Updated : November 15, 2024
Getting the smallest value using Math.Min() method
Here, we will get the smallest value from two numbers using Math.Min() method and then print the smallest value on the console screen.
VB.Net code to get the smallest value using Math.Min() method
The source code to get the smallest value using Math.Min() method is given below. The given program is compiled and executed successfully.
'VB.Net program to get small value using
'Min() method.
Module Module1
Sub Main()
Dim num1 As Decimal = 3.26
Dim num2 As Decimal = 4.28
Dim small As Decimal = 0
small = Math.Min(num1, num2)
Console.WriteLine("Small value: {0}", small)
End Sub
End Module
Output:
Small value: 3.26
Press any key to continue . . .
Explanation:
In the above program, we created a module Module1 that contains the Main() method. In the Main() method we created two local variables num1, num2 that are initialized with 3.26 and 4.28 respectively.
small = Math.Min(num1, num2)
Console.WriteLine("Small value: {0}", small)
Here, we used the Min() method of Math class. Here, we got the small value from variable num1 and num2 and assigned to variable small. After that, we printed the value small on the console screen.
VB.Net Basic Programs »