Home »
VB.Net »
VB.Net Programs
VB.Net program to find the logarithm value of a specified number
By Nidhi Last Updated : November 15, 2024
Finding the logarithm value of a specified number
Here, we will find the logarithm value of a specified number using the Log() method of Math class.
VB.Net code to find the logarithm value of a specified number
The source code to find the logarithm value of a specified number is given below. The given program is compiled and executed successfully.
'VB.Net program to find logarithm value
'of a specified number.
Module Module1
Sub Main()
'Find log value with base e
Console.WriteLine("Logarithm value with Base E")
Console.WriteLine(Math.Log(3))
Console.WriteLine(Math.Log(2.34))
Console.WriteLine(Math.Log(-2.56))
'Find log value with specified base.
Console.WriteLine("Logarithm value with specified Base")
Console.WriteLine(Math.Log(3, 1))
Console.WriteLine(Math.Log(2.34, 2))
Console.WriteLine(Math.Log(-2.56, 4))
End Sub
End Module
Output:
Logarithm value with Base E
1.09861228866811
0.85015092936961
NaN
Logarithm value with specified Base
NaN
1.22650852980868
NaN
Press any key to continue . . .
Explanation:
In the above program, we created a module Module1 that contains a method Main(). In the Main() method, we called the Log() method with different specified numbers.
'Find log value with base e
Console.WriteLine("Logarithm value with Base E")
Console.WriteLine(Math.Log(3))
Console.WriteLine(Math.Log(2.34))
Console.WriteLine(Math.Log(-2.56))
Here, we find the log value with base e and print the result on the console screen.
'Find log value with a specified base.
Console.WriteLine("Logarithm value with specified Base")
Console.WriteLine(Math.Log(3, 1))
Console.WriteLine(Math.Log(2.34, 2))
Console.WriteLine(Math.Log(-2.56, 4))
Here, we find the log value with a specified base and print the result on the console screen.
VB.Net Basic Programs »