Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Overflow Error

$
0
0
So... I'm trying to do a refresher on VB.NET coding since it's been about 3 years since I last coded...

My husband wanted me to try and code the challenge posted by this page: Golang Exercise 44

But I'm running into an overstack error when I run the code I have...

It ran once and gave me a wrong answer... Think my math problem maybe wrong somewhere but don't know where...

Help...

Module Module1

    Sub Main()
        Dim dbl As Double
        Dim returnedValue As Integer
        Dim str As String

        Console.WriteLine("Choose a number that you'd like to know the square root of.")

        str = Console.ReadLine()
        dbl = Convert.ToInt16(str)
        returnedValue = SquareRoot(dbl)

        Console.WriteLine("The square root of " & dbl & " is " & returnedValue & ".")
        Console.ReadLine()
    End Sub
    Function SquareRoot(ByVal z As Double)
        Dim count As Integer = 0

        Do
            z = z - (((z * z) - z) / 2 * z)
            count = count + 1
        Loop Until count > 10

        Return z
    End Function
End Module



What am I doing wrong?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>