title: VBA, CATIA Macro break loop
body: <p><a href="https://i.stack.imgur.com/JnSzk.png" rel="nofollow noreferrer">When I click the <code>Next</code> button on the form I would like to get the next part on the Form </a>
  I have a <code>for</code> loop that goes through Product Tree and reads <code>PartName</code> in variable <code>oForm.txtPartName</code>. On <code>oForm</code> there is a button <code>Next</code> and what it's supposed to do is break the <code>for</code> loop and jump on the next part on the tree. What code should I put into the <code>Next</code> button to get the job done?</p>
  <pre class="lang-vb prettyprint-override"><code>For i = 1 To oProducts.Count
         
      On Error Resume Next
      Set oPartDoc = oProducts.Item(i).ReferenceProduct.Parent
      
      Set oPart = oPartDoc.part
      
          If CInt(Mid(oPart.Name, 26, 3)) &gt; 100 Then
  
          oForm1.txtPartName = oPart.Name
          
          oForm1.Show
  
          End If
      Next i
  </code></pre>