title: Loop without Do error
body: <p>I'm trying to implement a simple Newton's method iterative solver using Excel VB (I have never used VB.)  </p>
  
  <p>I keep getting the error <code>loop without a Do</code> and I can't figure out what I'm doing wrong here.  </p>
  
  <p>I'm trying to find the roots of the function <code>z^3 - z^2 - (B^2 + B - A)z - A*B</code> called the compressibility factor.</p>
  
  <p>My source <a href="http://msdn.microsoft.com/en-us/library/eked04a7.aspx">MSN</a></p>
  
  <pre><code>Function zCalculation(ByVal temp As Double, ByVal press As Double) As Double
  
  Dim tempCr As Double
  Dim pressCr As Double
  Dim A As Double
  Dim B As Double
  
  tempCr = temp / 238.5
  
  pressCr = press / 547.424092
  
  A = pressCr / tempCr
  A = A / (9 * (2 ^ (1 / 3) - 1))
  B = pressCr / tempCr
  B = B * (2 ^ (1 / 3) - 1) / 3
  
  
  
  Dim zNot As Double
  Dim counter As Integer
  counter = 0
  zNot = 1#
  
  Do
      counter = counter + 1
  
      zNot = zNot - (zNot ^ 3 - zNot ^ 2 - (B ^ 2 + B - A) * zNot - A * B) / (3 * zNot ^ 2 - 2 * zNot - (B ^ 2 + B - A))
      If counter &gt; 1000 Then
         Exit Do
  
  Loop Until eval(zNot, A, B) &lt; 0.000001
  
  
  zCalculation = zNot
  
  
  End Function
  </code></pre>
  
  <p>break</p>
  
  <pre><code>Function eval(ByVal z As Double, ByVal A As Double, ByVal B As Double) As Double
  
      eval = z ^ 3 - z ^ 2 - (B ^ 2 + B - A) * z - A * B
  
  End Function
  </code></pre>