Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleCalculate the Nth root of a number in Visual Basic .NET
DescriptionThis example shows how to calculate the Nth root of a number in Visual Basic .NET.
Keywordsmathematics, roots, square roors, cube roots, find roots, Exp, Log, Visual Basic .NET, VB.NET
CategoriesAlgorithms
 

To calculate the Nth root of K you can simply use the formula:

    root = K1/N

The following code gets the numbers, calculates the root, and checks the result.

 
' Calculate the root.
Private Sub btnCalculate_Click(ByVal sender As _
    System.Object, ByVal e As System.EventArgs) Handles _
    btnCalculate.Click
    Dim number As Double = Double.Parse(txtNumber.Text)
    Dim root As Double = Double.Parse(txtRoot.Text)

    ' Calculate the root.
    Dim result As Double = Math.Pow(number, 1 / root)
    txtResult.Text = result.ToString()

    ' Check the result.
    Dim check As Double = Math.Pow(result, root)
    txtCheck.Text = check.ToString()
End Sub
 
 
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated