To find the square root of a number in Visual Basic, use the Sqr function. It's syntax is very simple:
Sqr(9) ' returns 3
One function that might not be quite so obvious is how to calculate the nth root of a number. To do this, all you need to do is use the following syntax:
nNumber ^ (1 / nRoot)
So, if you wanted to find the cubed root of 8 (ie root 3), all you need to do is
8 ^ (1 / 3)
and, if you wanted to find root 4 of 12, use
12 ^ (1 / 4)
Comments