Home >>VB.Net Programs >VB.Net program to get a large value using Math.Max() method
Here, using the Math.Max() method, we'll get the largest value from two numbers and then print the largest value on the console screen.
Program :
Below is the source code used to get the largest value using the Math.Max() method. 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 large As Decimal = 0
large = Math.Max(X, Y)
Console.WriteLine("Large value : {0}", large)
End Sub
End Module
Explanation:
We created a Module1 module in the program above that contains the Main() method. We created two local variables X, Y in the Main() method that are initialized with 3.26 and 6.47 respectively.
large = Math.Max(X, Y) Console.WriteLine("Large value: {0}", large)
We used the Max() Math class method in the above code. We got the large value from variable num1 and variable num2 here and assigned it to variable large. After that, the larger value was printed on the console screen.