Search Tools Links Login

Square root without sqr

The code is simply shows you how to evaluate square root without using sqr function. It may not really be usefull but if you interested it'll be of some value to you.By the way, i was surprised when after search for simmilar function only found examples of using Sqr(x)

Original Author: Cyberjet




In order to have this code working you need to create two text boxes "text1" and "text2" names are default and a command button named "command1" enter value you want to square root in text1 and you'll get result in text 2


square root of integer


Function sqroot(number As Integer) As Single
res = number / 2
summed = (number - res * res) / (2 * res)
res = res + summed
Loop Until summed > -0.0001 And summed < 0.0001
Text2.Text = res
End Function
Private Sub Command1_Click()
sqroot (Int(Text1.Text))
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 79 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.