Qbasicnews.com

Full Version: square rooting in VB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey,
can anyone tell me how to square root stuff inside a text box,cant seem to find out.
it's basicly this
Code:
Text1.Text = Sqr(Text1.Text)
not quite. i tried that and it didn't work for me. use this formula.
Code:
Num = val(text1.text)
Answer = Num^.5
easy...
Quote:it's basicly this
Code:
Text1.Text = Sqr(Text1.Text)
you just gotta do this:
Code:
Text1.Text = Str(SQR(Val(Text1.Text)))
it worked on mine without turning it into a string and back
Quote:...use this formula.
Code:
Num = val(text1.text)
Answer = Num^.5
Mech, that's brilliant! I never thought you could raise a number to .5 to get the square root. I wrote a little program to test it.

Who said you can't teach an old dog new tricks.
Thanks!
*****
Well, that's just math. The Nth root of a number is that number powered to the 1/Nth power.

[Image: img17.png]
*Zack runs in to give his useless two cents*
-(n^-1) is the negative reciprocal of a number.
Whatever. :roll:
Quote:it worked on mine without turning it into a string and back

VB has a "VARIANT" default. :*)
Quote:Well, that's just math. The Nth root of a number is that number powered to the 1/Nth power.

[Image: img17.png]


To be exactly....

nSQR is the n-th root of a number.

Code:
nSQR(x ^ p) = x ^ (p/n)
Pages: 1 2