×

VB.Net Programs

VB.Net program to get a large value using Math.Max() method

By Nidhi Last Updated : November 15, 2024

Getting a large value using Math.Max() method

Here, we will get the largest value from two numbers using Math.Max() method and then print the largest value on the console screen.

VB.Net code to get a large value using Math.Max() method

The source code to get the largest value using Math.Max() method is given below. The given program is compiled and executed successfully.

'VB.Net program to get large value using 
'Max() method.

Module Module1

    Sub Main()
        Dim num1 As Decimal = 3.26
        Dim num2 As Decimal = 4.28
        Dim large As Decimal = 0

        large = Math.Max(num1, num2)

        Console.WriteLine("Large value: {0}", large)
    End Sub

End Module

Output:

Large value: 4.28
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.

large = Math.Max(num1, num2)

Console.WriteLine("Large value: {0}", large)

In the above code, we used the Max() method of Math class. Here, we got the large value from variable num1 and num2 and assigned to variable large. After that, we printed the value large on the console screen.

VB.Net Basic Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.